ww-agentic-workflows 1.0.0.dev7__py3-none-any.whl → 1.0.0.dev8__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.
- ww/_bundled_extensions/ww/git/extension.py +22 -10
- ww/action_execution.py +18 -1
- ww/artifacts.py +16 -3
- ww/assets/docs/features.md +85 -8
- ww/assets/docs/specification.md +3 -2
- ww/assets/ww-debug-report_skill.md +9 -3
- ww/assets/ww_skill.md +4 -1
- ww/bootstrap.py +33 -7
- ww/child_coordination.py +22 -0
- ww/cli/audit.py +8 -0
- ww/cli/main.py +16 -1
- ww/cli/parser.py +22 -5
- ww/completion_artifacts.py +13 -12
- ww/execution_models/records.py +9 -1
- ww/instructions/builder.py +40 -0
- ww/instructions/commands.py +5 -0
- ww/instructions/models.py +9 -0
- ww/output_adapters/markdown.py +90 -7
- ww/plan/__init__.py +2 -0
- ww/plan/models.py +20 -0
- ww/results.py +2 -0
- ww/rule_verification.py +10 -3
- ww/run_reports.py +206 -4
- ww/service.py +162 -2
- ww/storage.py +4 -0
- ww/task_ids.py +11 -0
- ww/transitions.py +18 -7
- ww/variables.py +11 -0
- {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev8.dist-info}/METADATA +1 -1
- {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev8.dist-info}/RECORD +33 -33
- {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev8.dist-info}/WHEEL +0 -0
- {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev8.dist-info}/entry_points.txt +0 -0
- {ww_agentic_workflows-1.0.0.dev7.dist-info → ww_agentic_workflows-1.0.0.dev8.dist-info}/licenses/LICENSE +0 -0
|
@@ -435,6 +435,23 @@ def _tokens(context: ExtensionContext) -> dict[str, str]:
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
|
|
438
|
+
def _render_for_task(context: ExtensionContext, template: str) -> str:
|
|
439
|
+
"""Render ``template`` for the task as one name without the ID's slash.
|
|
440
|
+
|
|
441
|
+
A child task (``parent/child``) renders the template with the parent ID
|
|
442
|
+
and appends ``-<child>``, so its name sits beside the parent's rather than
|
|
443
|
+
under it; a template that renders empty stays empty for the caller to
|
|
444
|
+
refuse.
|
|
445
|
+
"""
|
|
446
|
+
tokens = _tokens(context)
|
|
447
|
+
task_id = context.task_id or ""
|
|
448
|
+
if "/" not in task_id:
|
|
449
|
+
return interpolate(template, tokens).strip()
|
|
450
|
+
parent_id, _, child_id = task_id.rpartition("/")
|
|
451
|
+
parent = interpolate(template, {**tokens, TASK_ID: parent_id}).strip()
|
|
452
|
+
return f"{parent}-{child_id}" if parent else ""
|
|
453
|
+
|
|
454
|
+
|
|
438
455
|
def _now() -> str:
|
|
439
456
|
return (
|
|
440
457
|
datetime.now(timezone.utc)
|
|
@@ -489,14 +506,7 @@ def _worktree_name(context: ExtensionContext, settings: Settings) -> str:
|
|
|
489
506
|
replaced by ``-``. Names a refusal must see (empty, ``.``, absolute) are
|
|
490
507
|
returned unchanged for the caller to reject.
|
|
491
508
|
"""
|
|
492
|
-
|
|
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}"
|
|
509
|
+
name = _render_for_task(context, settings.worktree_name_format)
|
|
500
510
|
if name and not Path(name).is_absolute() and "/" in name:
|
|
501
511
|
name = name.replace("/", "-")
|
|
502
512
|
return name
|
|
@@ -601,9 +611,11 @@ def _branch_name(
|
|
|
601
611
|
"""Render the task's branch from ``branch_format``: (branch, parent, error).
|
|
602
612
|
|
|
603
613
|
A child task's branch is its parent's recorded branch plus the child ID,
|
|
604
|
-
whatever the format says
|
|
614
|
+
whatever the format says; without a recorded parent branch it is the
|
|
615
|
+
format rendered for the parent plus the child ID, so a child's slash
|
|
616
|
+
never nests its branch under the parent's name.
|
|
605
617
|
"""
|
|
606
|
-
branch =
|
|
618
|
+
branch = _render_for_task(context, branch_format)
|
|
607
619
|
if not branch:
|
|
608
620
|
return None, None, "branch name format rendered empty"
|
|
609
621
|
parent_branch = _parent_branch(context)
|
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,
|
|
@@ -608,7 +610,22 @@ class ActionExecutor:
|
|
|
608
610
|
result=bounded(result.output, STATE_OUTPUT_PREVIEW_LIMIT).strip() or None,
|
|
609
611
|
output_values=tuple(result.values.items()),
|
|
610
612
|
)
|
|
611
|
-
values =
|
|
613
|
+
values = dict(dispatch.state.workflow_values)
|
|
614
|
+
# The values the handler consumed are asked for afresh by their next
|
|
615
|
+
# consumer, unless a later item of the same completion window still
|
|
616
|
+
# needs them; the handler's own outputs are kept as usual.
|
|
617
|
+
release_provided_values(
|
|
618
|
+
values,
|
|
619
|
+
item,
|
|
620
|
+
keep={
|
|
621
|
+
value.name
|
|
622
|
+
for later in completion_window_items(
|
|
623
|
+
snapshot.plan, dispatch.state.cursor
|
|
624
|
+
)[1:]
|
|
625
|
+
for value in later.provide
|
|
626
|
+
},
|
|
627
|
+
)
|
|
628
|
+
values.update(result.values)
|
|
612
629
|
completed = replace(
|
|
613
630
|
dispatch.state,
|
|
614
631
|
status="pending",
|
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:
|
|
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"
|
|
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
|
|
ww/assets/docs/features.md
CHANGED
|
@@ -1537,7 +1537,14 @@ manager continues. `awaiting_operator` means a human must decide; see
|
|
|
1537
1537
|
At handoff only the manager runs the displayed `next --role manager` command.
|
|
1538
1538
|
In the `auto` runtime the manager's delegate page and the requested worker
|
|
1539
1539
|
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
|
|
1540
|
+
and both the manager and the worker are told every item the assignment covers:
|
|
1541
|
+
`This assignment covers, in order: ...` while nothing is done, then, once the
|
|
1542
|
+
worker has completed some of them, `Already completed in this assignment: ...
|
|
1543
|
+
Remaining, in order: ...`, derived from the items' execution status rather
|
|
1544
|
+
than from the assignment's first item. The line is omitted when one item or
|
|
1545
|
+
none remains; while it is shown and ww is running an automatic item of the
|
|
1546
|
+
assignment, a commit hook or a push, it names it: `` `ww` is now running
|
|
1547
|
+
`git-push`. ``
|
|
1541
1548
|
A worker moving to a later item of the same assignment is told so explicitly,
|
|
1542
1549
|
and the end of an assignment says to stop and return to the manager.
|
|
1543
1550
|
|
|
@@ -2053,6 +2060,28 @@ without children, and a retried request that already bound its child simply
|
|
|
2053
2060
|
reports the bound task. A child added with an explicit `--id` skips the request,
|
|
2054
2061
|
as an explicit ID does for `start`.
|
|
2055
2062
|
|
|
2063
|
+
The identity page shows the child's text as its task requirements, and
|
|
2064
|
+
`requirements REQUEST-…` prints them while the request is open (a request has
|
|
2065
|
+
no run and no amendments). Wherever a request ID is accepted (`next`,
|
|
2066
|
+
`instruction`, `status`, `fail`, `complete`, `requirements`, `reset`), the
|
|
2067
|
+
parent-qualified name the parent's child record uses, `EPIC-1/REQUEST-…`,
|
|
2068
|
+
names the same request.
|
|
2069
|
+
|
|
2070
|
+
The identity step cannot be skipped, since there is no task without the
|
|
2071
|
+
external ID it obtains, so a failed request has two recoveries. `fail` shows
|
|
2072
|
+
them both:
|
|
2073
|
+
|
|
2074
|
+
```console
|
|
2075
|
+
ww-agentic-workflows next REQUEST-20260923101500123456 --retry --yes --role manager
|
|
2076
|
+
ww-agentic-workflows reset REQUEST-20260923101500123456 --yes
|
|
2077
|
+
```
|
|
2078
|
+
|
|
2079
|
+
`next --retry` reopens the failed request and dispatches the step again;
|
|
2080
|
+
`next --force` is refused for a request. `reset` removes the request and
|
|
2081
|
+
returns the parent's child record to pending, with its start operation kept,
|
|
2082
|
+
so `start-child EPIC-1 REQUEST-…` opens a fresh request for the same child. A
|
|
2083
|
+
request that has already bound its task is not reset; that task is.
|
|
2084
|
+
|
|
2056
2085
|
A child can also be named by the parent at collection time: with the parent as
|
|
2057
2086
|
an epic and its children as the epic's tasks, the agent creates each ticket,
|
|
2058
2087
|
then records it with `add-child EPIC-1 --id TASK-7 --text ...`, making the
|
|
@@ -2157,8 +2186,11 @@ the completion is rejected: nothing is saved, the artifact is kept only as a
|
|
|
2157
2186
|
draft, the step stays in progress with its worker, and `complete` exits
|
|
2158
2187
|
non-zero. The response is the fix page, `## Fix required: 2 of 5 checks failed
|
|
2159
2188
|
(attempt 1 of 3)`, with each failed check's rule text, command, and the last 40
|
|
2160
|
-
lines it printed,
|
|
2161
|
-
|
|
2189
|
+
lines it printed, the rejected artifact under `### Draft artifact`, then the
|
|
2190
|
+
same completion command; `fix_required` in JSON. The worker fixes the causes
|
|
2191
|
+
and completes again with the whole revised artifact, which replaces the draft
|
|
2192
|
+
entirely; the accepted artifact file keeps the rejected one under a
|
|
2193
|
+
**Previous attempt** heading.
|
|
2162
2194
|
|
|
2163
2195
|
A failed check always goes back to the worker, never to the operator, until
|
|
2164
2196
|
it has failed `max_fixes` times: the rule's own value, else `limits.fixes` in
|
|
@@ -2485,7 +2517,10 @@ hook to declare a transition.
|
|
|
2485
2517
|
Interpolations use `{{name}}`, with double braces everywhere. Every value ww
|
|
2486
2518
|
provides lives under `ww.`, so a name without it is always a variable a step
|
|
2487
2519
|
handed back: `{{ww.task.id}}` is the task's ID and `{{ww.task.workflows}}` the
|
|
2488
|
-
ordered workflow-name list, joined by commas.
|
|
2520
|
+
ordered workflow-name list, joined by commas. `{{ww.task.slug}}` is the task ID
|
|
2521
|
+
as one path component, each `/` of a child task's `parent/child` ID replaced
|
|
2522
|
+
by `-` (`TASK-42/A` reads `TASK-42-A`), for file names, branch names and other
|
|
2523
|
+
places a slash would nest or split the ID.
|
|
2489
2524
|
The core `{{ww.task.workspace_dir}}` variable is always the canonical directory for
|
|
2490
2525
|
the task: the project root by default, the configured project directory when a
|
|
2491
2526
|
task was started with `--project`, or the selected task checkout when an
|
|
@@ -2508,6 +2543,16 @@ the performer passes it with `complete --variable name=<value>`. A bare string,
|
|
|
2508
2543
|
`- name`, is a value an automatic action returns itself. A step's values are
|
|
2509
2544
|
available to its completion hooks and later plan items.
|
|
2510
2545
|
|
|
2546
|
+
A value an automatic handler asks for is consumed by it: once the handler has
|
|
2547
|
+
run with it, ww removes the value from the run again, unless a later hook of
|
|
2548
|
+
the same completion asks for it too, in which case it stays until that hook
|
|
2549
|
+
has run. The next handler that asks for the same name, a `git-commit` after a
|
|
2550
|
+
review loop or one that is a step of its own, therefore requests it afresh
|
|
2551
|
+
(`awaiting_input`) instead of running silently with the message an earlier
|
|
2552
|
+
step supplied. A failed handler releases its values the same way when it is
|
|
2553
|
+
retried, keeping them on its record so the request can show what it was given
|
|
2554
|
+
last time.
|
|
2555
|
+
|
|
2511
2556
|
When several automatic completion hooks request the same variable with the
|
|
2512
2557
|
same description, ww asks for it once and gives that value to each hook.
|
|
2513
2558
|
For example, project and workflow commit hooks share one `commit_message`.
|
|
@@ -2950,6 +2995,14 @@ steps/
|
|
|
2950
2995
|
02-fix.md
|
|
2951
2996
|
```
|
|
2952
2997
|
|
|
2998
|
+
The `Step N of M` line in each step artifact's workflow context uses the same
|
|
2999
|
+
ordinals: `N` is the file's ordinal, dotted for a nested step (`02-fix.md`
|
|
3000
|
+
under `03-plan-and-fix/` reads `Step 3.2 of 3`), and `M` is the number of
|
|
3001
|
+
top-level steps the workflow declares, so a group counts once and the total
|
|
3002
|
+
does not change when items, children or a replan add plan items mid-run. The
|
|
3003
|
+
artifact of a step performed by an identity request (`REQUEST-…`) is
|
|
3004
|
+
numbered the same way once it is written into the bound task.
|
|
3005
|
+
|
|
2953
3006
|
Loop bodies add an `iteration-NN` directory beneath each loop wrapper. Every
|
|
2954
3007
|
round therefore keeps its own step and hook artifacts instead of overwriting
|
|
2955
3008
|
the files from an earlier round:
|
|
@@ -3727,8 +3780,12 @@ and return-to-base use one stable value. The record is trusted only while it
|
|
|
3727
3780
|
names the branch being resolved and that branch exists; a record of another
|
|
3728
3781
|
branch, or of a deleted one, is left behind by an earlier task under the same
|
|
3729
3782
|
ID, and the configured base is resolved instead. A child task always uses its
|
|
3730
|
-
recorded parent task branch instead
|
|
3731
|
-
|
|
3783
|
+
recorded parent task branch instead, and its branch is that branch plus
|
|
3784
|
+
`-<child id>`; without a recorded parent branch, the format is rendered for the
|
|
3785
|
+
parent ID and `-<child id>` appended, so `TASK-51/A` under
|
|
3786
|
+
`feature/{{ww.task.id}}` is `feature/task-51-a`, never a `feature/task-51/a`
|
|
3787
|
+
that Git would refuse beside `feature/task-51`. `reset` drops the task's branch
|
|
3788
|
+
and commit records, and its children's.
|
|
3732
3789
|
|
|
3733
3790
|
`branch_name_formats` names the available branch naming strategies. Without an
|
|
3734
3791
|
override, `start-task-branch` first looks for a strategy matching the workflow
|
|
@@ -4722,23 +4779,43 @@ ww writes the record: the workflow's name, the time, the task and run IDs, the
|
|
|
4722
4779
|
agent, runtime and modes, the ww version with the plan and task-state schema
|
|
4723
4780
|
versions, the workflow's definition as written in `ww.yaml` (not the compiled
|
|
4724
4781
|
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
|
|
4782
|
+
`TASK-42--01-task`; a child task's slash becomes a dash, as in
|
|
4783
|
+
`{{ww.task.slug}}` (`TASK-42-A--01-task`).
|
|
4726
4784
|
|
|
4727
4785
|
The agent is told about the collection exactly once: the first page of a run
|
|
4728
4786
|
asks it to say that ww collects debug info or feedback at the end of the run,
|
|
4729
4787
|
that it stays on this machine, and where. The collection itself is silent
|
|
4730
4788
|
until the summary step. Nothing is ever sent by itself.
|
|
4731
4789
|
|
|
4790
|
+
A debug record also carries an `events` array, apart from the agent's two
|
|
4791
|
+
arrays, with what ww itself observed while `debug.collect` was on: a `fail`
|
|
4792
|
+
(on a task or on an identity request, with the error), a `next --force` with
|
|
4793
|
+
what it forced and the operator's reason, a `dispute`, and every stop for the
|
|
4794
|
+
operator (the `operator_reason` and the error, once per stop, not on every
|
|
4795
|
+
reading of the page). Each event has `at`, `source` (`ww`, or `operator` for
|
|
4796
|
+
a note) and `summary`, plus `detail`. Events wait under
|
|
4797
|
+
`.ww/debug/pending/` until the run completes, when the record takes them
|
|
4798
|
+
over; the events of an identity request go to the record of the task the
|
|
4799
|
+
request bound.
|
|
4800
|
+
|
|
4732
4801
|
```console
|
|
4733
4802
|
./ww debug list
|
|
4734
4803
|
./ww debug show TASK-42--01-task
|
|
4804
|
+
./ww debug note TASK-42 --summary "The fix page named the wrong step" --detail "..."
|
|
4735
4805
|
./ww workflow-feedback list
|
|
4736
4806
|
./ww workflow-feedback show TASK-42--01-task --json
|
|
4737
4807
|
```
|
|
4738
4808
|
|
|
4739
4809
|
`list` names every record with its counts and whether it was reported;
|
|
4740
4810
|
`show` prints one as Markdown, exactly what a report would send; `--json`
|
|
4741
|
-
gives the records themselves.
|
|
4811
|
+
gives the records themselves. `note` keeps the operator's own observation of
|
|
4812
|
+
ww's behaviour: given a record ID, or a task whose run completed, the note is
|
|
4813
|
+
added to that record's events; given a task still running or an identity
|
|
4814
|
+
request, it waits with the pending events for the run's record and is also
|
|
4815
|
+
written as a standalone record (`TASK-42--notes`, empty agent arrays), which
|
|
4816
|
+
the run's own record replaces once it completes, so a note on a run that
|
|
4817
|
+
never completes is still kept. The note is written whether or not
|
|
4818
|
+
`debug.collect` is on.
|
|
4742
4819
|
|
|
4743
4820
|
### Reporting debug records
|
|
4744
4821
|
|
ww/assets/docs/specification.md
CHANGED
|
@@ -17,8 +17,9 @@ and `ww docs examples` (`docs` is read-only and takes no project state).
|
|
|
17
17
|
- **Template:** `{{variable}}`, double braces everywhere. A name without
|
|
18
18
|
`ww.` is always a variable an earlier step handed back (`variables`) or an
|
|
19
19
|
automatic action returned. Every value ww provides lives under `ww.`:
|
|
20
|
-
`{{ww.task.id}}`, `{{ww.task.
|
|
21
|
-
|
|
20
|
+
`{{ww.task.id}}`, `{{ww.task.slug}}` (the task ID as one path component,
|
|
21
|
+
a child's `/` replaced by `-`), `{{ww.task.workspace_dir}}`,
|
|
22
|
+
`{{ww.task.workflows}}` (the configured workflow names), `{{ww.project.name}}`,
|
|
22
23
|
`{{ww.project.dir}}`, `{{ww.project.names}}`, `{{ww.executable}}` (how
|
|
23
24
|
printed commands invoke ww: `./ww` or the configured `executable`),
|
|
24
25
|
`{{ww.documents.<name>}}`,
|
|
@@ -6,9 +6,15 @@ description: Report the debug records ww collected about its own behaviour to ww
|
|
|
6
6
|
# Report ww's debug records
|
|
7
7
|
|
|
8
8
|
ww's `debug.collect` mode keeps a local record per workflow run of how ww
|
|
9
|
-
itself behaved: errors, bugs and blockers first, then inconveniences
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
itself behaved: errors, bugs and blockers first, then inconveniences, then
|
|
10
|
+
the events ww observed on its own (a `fail`, a forced `next`, a dispute,
|
|
11
|
+
every stop for the operator) and the operator's notes. Nothing is sent by
|
|
12
|
+
itself. Reporting is the operator's explicit decision, record by record, and
|
|
13
|
+
ww does the sending, not you.
|
|
14
|
+
|
|
15
|
+
When the operator tells you something ww did wrong that no record holds yet,
|
|
16
|
+
keep it with `./ww debug note <record-id|task-id|request-id> --summary "…"
|
|
17
|
+
[--detail "…"]`; it lands on the record, or waits for the run's record.
|
|
12
18
|
|
|
13
19
|
1. Run `./ww debug list`. If it shows no unreported record, say so and stop.
|
|
14
20
|
2. For each unreported record, run `./ww debug show <record-id>` and show the
|
ww/assets/ww_skill.md
CHANGED
|
@@ -74,4 +74,7 @@ change, start from step 1 then.
|
|
|
74
74
|
handler again, `--force --reason` to skip it or leave the loop, or
|
|
75
75
|
`--replan` / `--keep-plan` for a changed workflow. A `pass_incomplete`
|
|
76
76
|
stop is cleared by recording what it names with `./ww update-item`, then
|
|
77
|
-
`./ww next <task-id> --retry`; `--force` is refused there.
|
|
77
|
+
`./ww next <task-id> --retry`; `--force` is refused there. A failed
|
|
78
|
+
identity request (`REQUEST-…`) is only retried with `--retry` or dropped
|
|
79
|
+
with `./ww reset <request-id> --yes`, both shown on its page; `--force`
|
|
80
|
+
is refused there too.
|
ww/bootstrap.py
CHANGED
|
@@ -12,7 +12,7 @@ from ww.completion_inputs import validate_requested_values, validate_values
|
|
|
12
12
|
from ww.errors import ConfigurationError, StateError
|
|
13
13
|
from ww.extensions import ExtensionRegistry
|
|
14
14
|
from ww.instructions import Instruction, action_text, build_bootstrap_instruction
|
|
15
|
-
from ww.plan import PlanCompilationOptions, PlanItem, compile_workflow_plan
|
|
15
|
+
from ww.plan import PlanCompilationOptions, PlanItem, compile_workflow_plan, step_label
|
|
16
16
|
from ww.storage import Storage
|
|
17
17
|
from ww.storage_adapters import ArtifactAddress, TaskStorageAdapter
|
|
18
18
|
from ww.task_ids import validate_child_id
|
|
@@ -191,6 +191,7 @@ class BootstrapCoordinator:
|
|
|
191
191
|
"step": item.step,
|
|
192
192
|
"item_id": item.id,
|
|
193
193
|
"item_name": item.name,
|
|
194
|
+
"step_ordinals": list(item.step_ordinals),
|
|
194
195
|
"action_kind": item.kind,
|
|
195
196
|
"action_text": action_text(item),
|
|
196
197
|
"profile_instruction": item.profile_instruction,
|
|
@@ -211,8 +212,9 @@ class BootstrapCoordinator:
|
|
|
211
212
|
def next(
|
|
212
213
|
self,
|
|
213
214
|
request: dict[str, object],
|
|
214
|
-
force: bool,
|
|
215
215
|
*,
|
|
216
|
+
retry: bool = False,
|
|
217
|
+
force: bool = False,
|
|
216
218
|
selected_agent: str | None,
|
|
217
219
|
selected_model: str | None,
|
|
218
220
|
selected_reasoning: str | None,
|
|
@@ -220,6 +222,16 @@ class BootstrapCoordinator:
|
|
|
220
222
|
status_task: ReadWorkflowStatus,
|
|
221
223
|
bind_child: BindChild | None = None,
|
|
222
224
|
) -> Instruction:
|
|
225
|
+
"""Dispatch the identity step; ``retry`` reopens it after a failure.
|
|
226
|
+
|
|
227
|
+
The step cannot be skipped: without an external ID there is no task,
|
|
228
|
+
so ``force`` is refused and a failed request is retried or reset.
|
|
229
|
+
"""
|
|
230
|
+
if force:
|
|
231
|
+
raise StateError(
|
|
232
|
+
"an identity request cannot be skipped; use next --retry to "
|
|
233
|
+
"reopen it, or reset it"
|
|
234
|
+
)
|
|
223
235
|
status = request.get("status")
|
|
224
236
|
if status == "completed":
|
|
225
237
|
raise StateError("bootstrap request is already completed")
|
|
@@ -239,10 +251,12 @@ class BootstrapCoordinator:
|
|
|
239
251
|
"binding bootstrap request is missing its resolved task ID"
|
|
240
252
|
)
|
|
241
253
|
if status == "failed":
|
|
242
|
-
if not
|
|
254
|
+
if not retry:
|
|
243
255
|
return self.instruction(request)
|
|
244
256
|
request["status"] = "pending"
|
|
245
257
|
request.pop("error", None)
|
|
258
|
+
elif retry:
|
|
259
|
+
raise StateError("the identity request has not failed; nothing to retry")
|
|
246
260
|
if request.get("status") == "in_progress":
|
|
247
261
|
raise StateError("a bootstrap step is already in progress; use complete")
|
|
248
262
|
request["status"] = "in_progress"
|
|
@@ -370,7 +384,19 @@ class BootstrapCoordinator:
|
|
|
370
384
|
)
|
|
371
385
|
if artifact is not None:
|
|
372
386
|
run_id = self.tasks.active_execution_run(resolved_id)
|
|
373
|
-
|
|
387
|
+
snapshot = (
|
|
388
|
+
self.tasks.read_plan_snapshot(resolved_id, run_id)
|
|
389
|
+
if run_id is not None
|
|
390
|
+
else None
|
|
391
|
+
)
|
|
392
|
+
if snapshot is not None:
|
|
393
|
+
# The run's plan was numbered with the bootstrap step and
|
|
394
|
+
# then dropped it: its recorded ordinals name the file
|
|
395
|
+
# and, with the run's, the ``Step N of M`` label.
|
|
396
|
+
step_ordinals = tuple(cast(list[int], request["step_ordinals"]))
|
|
397
|
+
step_number, step_total = step_label(
|
|
398
|
+
step_ordinals, snapshot.plan.items
|
|
399
|
+
)
|
|
374
400
|
self.tasks.write_execution_artifact(
|
|
375
401
|
ArtifactAddress(
|
|
376
402
|
resolved_id,
|
|
@@ -380,14 +406,14 @@ class BootstrapCoordinator:
|
|
|
380
406
|
str(request["item_name"]),
|
|
381
407
|
"step",
|
|
382
408
|
run_id=run_id,
|
|
383
|
-
step_ordinals=
|
|
409
|
+
step_ordinals=step_ordinals,
|
|
384
410
|
),
|
|
385
411
|
render_step_artifact(
|
|
386
412
|
task_id=resolved_id,
|
|
387
413
|
workflow=workflow,
|
|
388
414
|
step=step,
|
|
389
|
-
step_number=
|
|
390
|
-
step_total=
|
|
415
|
+
step_number=step_number,
|
|
416
|
+
step_total=step_total,
|
|
391
417
|
skill="auto",
|
|
392
418
|
result=artifact,
|
|
393
419
|
),
|
ww/child_coordination.py
CHANGED
|
@@ -235,6 +235,28 @@ class ChildCoordinator:
|
|
|
235
235
|
agent=resolved_agent,
|
|
236
236
|
)
|
|
237
237
|
|
|
238
|
+
def release_child(self, parent_task_id: str, child_id: str) -> None:
|
|
239
|
+
"""Return a child whose identity request was reset to ``pending``.
|
|
240
|
+
|
|
241
|
+
The record keeps its start operation and frozen launch settings, so
|
|
242
|
+
``start-child`` opens a fresh request for it as it did the first time.
|
|
243
|
+
"""
|
|
244
|
+
with self.tasks.lock_task(parent_task_id):
|
|
245
|
+
parent, snapshot = self.lifecycle.load(parent_task_id)
|
|
246
|
+
children = list(self.tasks.read_children(parent_task_id, parent.run_id))
|
|
247
|
+
index = next(
|
|
248
|
+
(
|
|
249
|
+
i
|
|
250
|
+
for i, entry in enumerate(children)
|
|
251
|
+
if entry.id == child_id and entry.status == "starting"
|
|
252
|
+
),
|
|
253
|
+
None,
|
|
254
|
+
)
|
|
255
|
+
if index is None:
|
|
256
|
+
return
|
|
257
|
+
children[index] = replace(children[index], status="pending")
|
|
258
|
+
self.lifecycle.commit(parent, snapshot, children=tuple(children))
|
|
259
|
+
|
|
238
260
|
def bind_child(
|
|
239
261
|
self, parent_task_id: str, temporary_id: str, child_task_id: str
|
|
240
262
|
) -> None:
|
ww/cli/audit.py
CHANGED
|
@@ -117,6 +117,14 @@ def _invocation(args: argparse.Namespace) -> str:
|
|
|
117
117
|
values.extend(["--metadata", _redacted_variable(metadata_value)])
|
|
118
118
|
if args.command == "fail":
|
|
119
119
|
values.extend(["--error", "<redacted>"])
|
|
120
|
+
if args.command == "debug":
|
|
121
|
+
values.append(args.debug_action)
|
|
122
|
+
if args.record_id:
|
|
123
|
+
values.append(args.record_id)
|
|
124
|
+
if args.debug_action == "note":
|
|
125
|
+
values.extend(["--summary", "<redacted>"])
|
|
126
|
+
if args.detail is not None:
|
|
127
|
+
values.extend(["--detail", "<redacted>"])
|
|
120
128
|
if args.command == "reset" and args.yes:
|
|
121
129
|
values.append("--yes")
|
|
122
130
|
if getattr(args, "json_output", False):
|
ww/cli/main.py
CHANGED
|
@@ -1071,6 +1071,21 @@ def _debug(context: _Context) -> _Outcome:
|
|
|
1071
1071
|
return _Outcome(
|
|
1072
1072
|
_json(record) if args.json_output else render_record(record, DEBUG)
|
|
1073
1073
|
)
|
|
1074
|
+
if args.debug_action == "note":
|
|
1075
|
+
if not args.record_id:
|
|
1076
|
+
raise StateError("debug note needs a record, task or request ID")
|
|
1077
|
+
if not (args.summary or "").strip():
|
|
1078
|
+
raise StateError("debug note needs --summary")
|
|
1079
|
+
noted = context.service.debug_note(
|
|
1080
|
+
args.record_id, summary=args.summary, detail=args.detail
|
|
1081
|
+
)
|
|
1082
|
+
where = (
|
|
1083
|
+
f"kept with the pending events of `{noted['target']}` and in the "
|
|
1084
|
+
f"standalone record `{noted['record']}` until its run completes"
|
|
1085
|
+
if noted["pending"]
|
|
1086
|
+
else f"added to record `{noted['record']}`"
|
|
1087
|
+
)
|
|
1088
|
+
return _Outcome(_json(noted) if args.json_output else f"Note {where}.\n")
|
|
1074
1089
|
records = [store.get(args.record_id)] if args.record_id else store.unreported()
|
|
1075
1090
|
if not records:
|
|
1076
1091
|
text = "No unreported debug records.\n"
|
|
@@ -1702,7 +1717,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1702
1717
|
and (args.feedback_action not in {"record", "prune"} or args.dry_run)
|
|
1703
1718
|
)
|
|
1704
1719
|
or (args.command == "onboarding" and not args.assignments)
|
|
1705
|
-
or (args.command == "debug" and args.debug_action
|
|
1720
|
+
or (args.command == "debug" and args.debug_action not in {"report", "note"})
|
|
1706
1721
|
)
|
|
1707
1722
|
|
|
1708
1723
|
def log(outcome: str, error: str | None, *scope: str | None) -> None:
|
ww/cli/parser.py
CHANGED
|
@@ -503,15 +503,32 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
503
503
|
"debug",
|
|
504
504
|
parents=[json_output],
|
|
505
505
|
help=(
|
|
506
|
-
"List, show or report the debug records ww collected about
|
|
507
|
-
"behaviour (ww.json debug.collect);
|
|
508
|
-
"
|
|
506
|
+
"List, show, note or report the debug records ww collected about "
|
|
507
|
+
"its own behaviour (ww.json debug.collect); note keeps the "
|
|
508
|
+
"operator's observation on a record, task or request; report "
|
|
509
|
+
"sends one GitHub issue per record, each shown in full and "
|
|
510
|
+
"confirmed first."
|
|
509
511
|
),
|
|
510
512
|
)
|
|
511
513
|
debug.add_argument(
|
|
512
|
-
"debug_action",
|
|
514
|
+
"debug_action",
|
|
515
|
+
choices=["list", "show", "report", "note"],
|
|
516
|
+
nargs="?",
|
|
517
|
+
default="list",
|
|
518
|
+
)
|
|
519
|
+
debug.add_argument(
|
|
520
|
+
"record_id",
|
|
521
|
+
nargs="?",
|
|
522
|
+
help="A record ID; for note, also a task ID or a request ID.",
|
|
523
|
+
)
|
|
524
|
+
debug.add_argument(
|
|
525
|
+
"--summary",
|
|
526
|
+
help=(
|
|
527
|
+
"note: the operator's one-sentence note on how ww behaved, kept "
|
|
528
|
+
"on the target's debug record or with its pending events."
|
|
529
|
+
),
|
|
513
530
|
)
|
|
514
|
-
debug.add_argument("
|
|
531
|
+
debug.add_argument("--detail", help="note: what happened, in full.")
|
|
515
532
|
debug.add_argument(
|
|
516
533
|
"--yes",
|
|
517
534
|
action="store_true",
|
ww/completion_artifacts.py
CHANGED
|
@@ -7,7 +7,7 @@ from ww.actions import PlannedAction, actions
|
|
|
7
7
|
from ww.artifacts import RuleOutcome, RulesSummary, RuleStatus, render_step_artifact
|
|
8
8
|
from ww.contracts import CheckStatus
|
|
9
9
|
from ww.execution_models import CheckReport, ExecutionState, PlanSnapshot
|
|
10
|
-
from ww.plan import PlanItem
|
|
10
|
+
from ww.plan import PlanItem, step_label
|
|
11
11
|
from ww.rule_checks import item_reports
|
|
12
12
|
from ww.storage_adapters.base import ArtifactAddress, TaskArtifactStorage
|
|
13
13
|
|
|
@@ -94,10 +94,15 @@ def write_completion_artifacts(
|
|
|
94
94
|
"""Write the completed item and optional enclosing-loop artifacts.
|
|
95
95
|
|
|
96
96
|
``rules`` is the completed item's own rule report; a loop wrapper's
|
|
97
|
-
artifact carries none.
|
|
97
|
+
artifact carries none. The artifact of the completion rejected before
|
|
98
|
+
this one, when there was one, follows the result as the item's previous
|
|
99
|
+
attempt: a hold carries the draft it displaced, else the record does.
|
|
98
100
|
"""
|
|
99
101
|
if artifact is None:
|
|
100
102
|
return None, None
|
|
103
|
+
record = state.item_executions[state.cursor]
|
|
104
|
+
held = record.held_completion
|
|
105
|
+
previous = held.previous_artifact if held is not None else record.draft_artifact
|
|
101
106
|
|
|
102
107
|
def attribution(plan_item: PlanItem) -> str:
|
|
103
108
|
if not isinstance(plan_item.operation, PlannedAction):
|
|
@@ -105,24 +110,20 @@ def write_completion_artifacts(
|
|
|
105
110
|
action = actions.get(plan_item.kind)
|
|
106
111
|
return action.traits(plan_item.operation.payload).artifact_attribution
|
|
107
112
|
|
|
108
|
-
step_paths = tuple(
|
|
109
|
-
dict.fromkeys(
|
|
110
|
-
plan_item.step
|
|
111
|
-
for plan_item in snapshot.plan.items
|
|
112
|
-
if plan_item.phase == "step"
|
|
113
|
-
)
|
|
114
|
-
)
|
|
115
|
-
|
|
116
113
|
def rendered(plan_item: PlanItem) -> str:
|
|
114
|
+
step_number, step_total = step_label(
|
|
115
|
+
plan_item.step_ordinals, snapshot.plan.items
|
|
116
|
+
)
|
|
117
117
|
return render_step_artifact(
|
|
118
118
|
task_id=task_id,
|
|
119
119
|
workflow=state.workflow,
|
|
120
120
|
step=plan_item.step,
|
|
121
|
-
step_number=
|
|
122
|
-
step_total=
|
|
121
|
+
step_number=step_number,
|
|
122
|
+
step_total=step_total,
|
|
123
123
|
skill=attribution(plan_item),
|
|
124
124
|
result=artifact,
|
|
125
125
|
rules=rules if plan_item is item else None,
|
|
126
|
+
previous_attempt=previous if plan_item is item else None,
|
|
126
127
|
)
|
|
127
128
|
|
|
128
129
|
def write(plan_item: PlanItem, content: str) -> str:
|
ww/execution_models/records.py
CHANGED
|
@@ -244,7 +244,9 @@ class HeldCompletion:
|
|
|
244
244
|
are the change set the verifiers look at; ``draft_ref`` is where the
|
|
245
245
|
draft artifact was written for them. ``verdicts`` collect across the
|
|
246
246
|
verification rounds of this hold; ``report`` is the passing check report,
|
|
247
|
-
reused while the working tree has not changed.
|
|
247
|
+
reused while the working tree has not changed. ``previous_artifact`` is
|
|
248
|
+
the rejected draft this completion displaced, kept for the artifact's
|
|
249
|
+
history.
|
|
248
250
|
"""
|
|
249
251
|
|
|
250
252
|
variables: tuple[tuple[str, str], ...] = ()
|
|
@@ -261,6 +263,7 @@ class HeldCompletion:
|
|
|
261
263
|
draft_ref: str | None = None
|
|
262
264
|
verdicts: tuple[RuleVerdict, ...] = ()
|
|
263
265
|
report: CheckReport | None = None
|
|
266
|
+
previous_artifact: str | None = None
|
|
264
267
|
|
|
265
268
|
def __post_init__(self) -> None:
|
|
266
269
|
if self.loop_control not in {None, "break", "continue"}:
|
|
@@ -285,6 +288,7 @@ class HeldCompletion:
|
|
|
285
288
|
"draft_ref": self.draft_ref,
|
|
286
289
|
"verdicts": [verdict.to_dict() for verdict in self.verdicts],
|
|
287
290
|
"report": self.report.to_dict() if self.report else None,
|
|
291
|
+
"previous_artifact": self.previous_artifact,
|
|
288
292
|
}
|
|
289
293
|
|
|
290
294
|
@classmethod
|
|
@@ -307,6 +311,7 @@ class HeldCompletion:
|
|
|
307
311
|
"draft_ref",
|
|
308
312
|
"verdicts",
|
|
309
313
|
"report",
|
|
314
|
+
"previous_artifact",
|
|
310
315
|
},
|
|
311
316
|
"held completion",
|
|
312
317
|
)
|
|
@@ -348,6 +353,9 @@ class HeldCompletion:
|
|
|
348
353
|
if data["report"] is not None
|
|
349
354
|
else None
|
|
350
355
|
),
|
|
356
|
+
previous_artifact=expect_optional_string(
|
|
357
|
+
data["previous_artifact"], "held completion.previous_artifact"
|
|
358
|
+
),
|
|
351
359
|
)
|
|
352
360
|
|
|
353
361
|
|