44This document is the canonical discussion surface for the full task lifecycle:
55- status transitions
66- execution and review loops
7- - rejection handling and restart paths
8- - follow-up task linkage
7+ - rejection handling and replacement-attempt lineage
8+ - initiative progression and review gates
99
10- It reflects the current implementation and highlights places where behavior can be evolved .
10+ This document now reflects the intended target behavior for implementation .
1111
1212## Lifecycle State Machine
13- Current transitions (from ` ALLOWED_TASK_TRANSITIONS ` ) are:
13+ Target transitions (single task record ) are:
1414- ` pending -> in_progress | canceled `
1515- ` in_progress -> completed | blocked `
1616- ` blocked -> in_progress | canceled `
1717- ` completed -> approved | rejected `
18- - ` rejected -> pending | canceled `
18+ - ` rejected -> canceled `
1919- ` approved ` is terminal
2020- ` canceled ` is terminal
2121
@@ -34,7 +34,6 @@ stateDiagram-v2
3434 completed --> approved
3535 completed --> rejected
3636
37- rejected --> pending
3837 rejected --> canceled
3938
4039 approved --> [*]
@@ -56,33 +55,50 @@ flowchart TB
5655 A02{"Tasks already exist for initiative?"}
5756 A03["System3 creates task records"]
5857 A04["New tasks start as pending"]
59- A05["System3 picks next existing task"]
60- A["System3 assigns task"]
61- NX2{"Next task available?"}
62- NX3["System3 assigns next task in initiative"]
63- NX4["No remaining tasks in initiative"]
64- IR1["System3 -> System4: InitiativeReviewMessage"]
58+ A05["System3 picks next existing pending task"]
59+ A["System3 selects best suited System1 to assign task to"]
60+
6561 F["System3 task review"]
6662 G{"Task status review-eligible?"}
6763 H["Error: invalid review status for TaskReviewMessage"]
68- H2["System3 resets task status to pending"]
64+ H3{"Invalid-review auto-retry count < 3?"}
65+ H2["System3 resets task status to pending and clears assignee"]
66+ H4["System3 stops auto-retry and waits for System5 remediation"]
67+
6968 I{"Blocked or Completed path"}
7069 J0["System3 enters blocked-resolution loop"]
7170 J1{"Blocked-resolution action"}
7271 J3["System3 modifies task"]
7372 J4["System3 sets task status to pending and restarts execution"]
73+
7474 M["Policy judgement cases"]
7575 N{"Outcome"}
7676 O["Task -> approved"]
7777 P1["System3 -> System5: PolicyVagueMessage"]
7878 P3["System5 -> System3: TaskReviewMessage"]
7979 P4["System3 reruns policy review"]
8080 Q["Task -> rejected"]
81+
8182 R{"Rejection handling decision"}
83+ RR1["System3 prepares improved replacement task spec"]
8284 R0["System3 compiles rejection evidence"]
8385 R1["System3 -> System5: remediation request"]
86+
87+ RC["Task -> canceled (archive rejected attempt)"]
88+ T1["System3 creates replacement task (same initiative)"]
89+ T2["Replacement task starts as pending"]
90+ T3["Original.follow_up_task_ids += replacement_task_id"]
91+ T4["Replacement.replaces_task_id = original_task_id"]
92+
8493 L["Task -> canceled"]
85- NX1["System3 checks remaining tasks in initiative"]
94+
95+ NX1["System3 inspects initiative task states"]
96+ NX2{"All tasks terminal (approved|canceled)?"}
97+ NX3{"Any pending tasks to assign?"}
98+ NX4["No remaining tasks in initiative"]
99+ NX5["System3 waits for active in_progress/blocked tasks"]
100+ NX6["System3 assigns next pending task in initiative"]
101+ IR1["System3 -> System4: InitiativeReviewMessage"]
86102 S1S
87103 end
88104 subgraph S4S["System4 Scope (Intelligence)"]
@@ -103,34 +119,43 @@ flowchart TB
103119 subgraph US["User Scope (External)"]
104120 U1["User notified / manual intervention"]
105121 end
106- J3 --> J4
107122 A0 --> A01
108123 A01 --> A02
109124 A02 -- no --> A03
110125 A03 --> A04
111126 A04 --> A
112127 A02 -- yes --> A05
113128 A05 --> A
129+
114130 A --> A1
115131 A1 --> B
116132 B --> C
117- C -- "status=done" --> D
118- C -- "status=blocked" --> E
133+ C -- status=done --> D
134+ C -- status=blocked --> E
135+
119136 D --> F
120137 E --> F
138+
121139 F --> G
122140 G -- no --> H
123- H --> H1 & H2
124- H2 --> A
141+ H --> H3
142+ H3 -- yes --> H1
143+ H3 -- yes --> H2
144+ H2 --> A05
145+ H3 -- no --> H1
146+ H3 -- no --> H4
147+
125148 G -- yes --> I
126149 I -- blocked --> J0
127150 J0 --> J1
128151 J1 -- request research --> J2
129152 J2 --> J3
130- J1 -- System1 not equipped --> R1
131153 J1 -- modify and restart directly --> J3
132- J4 --> A
154+ J3 --> J4
155+ J4 --> A05
156+ J1 -- System1 not equipped --> R1
133157 J1 -- cancel --> L
158+
134159 I -- completed --> M
135160 M --> N
136161 N -- all satisfied --> O
@@ -140,27 +165,38 @@ flowchart TB
140165 P3 --> P4
141166 P4 --> F
142167 N -- violated and no vague --> Q
143- O --> NX1
144- L --> NX1
145- NX1 --> NX2
146- NX2 -- yes --> NX3
147- NX3 --> A05
148- NX2 -- no --> NX4
149- NX4 --> IR1
150- IR1 --> IR2
151- IR2 --> A01
168+
152169 Q --> R
153- R -- Existing System1 with better information/prompt --> J1
170+ R -- existing System1 can pass with better information/prompt --> RR1
154171 R -- System1 change required --> R0
172+ RR1 --> RC
155173 R0 --> R1
156174 R1 --> R2
157175 R2 -- System1 config/skills updated --> R21
158176 R2 -- New System1 profile authorized --> R22
159- R21 --> J4
160- R22 --> J4
177+ R21 --> RC
178+ R22 --> RC
161179 R2 -- No viable remediation --> R011
162180 R011 --> U1
163181 U1 --> L
182+
183+ RC --> T1
184+ T1 --> T2
185+ T2 --> T3
186+ T3 --> T4
187+ T4 --> A05
188+
189+ O --> NX1
190+ L --> NX1
191+ NX1 --> NX2
192+ NX2 -- yes --> NX4
193+ NX4 --> IR1
194+ IR1 --> IR2
195+ IR2 --> A01
196+ NX2 -- no --> NX3
197+ NX3 -- yes --> NX6
198+ NX6 --> A05
199+ NX3 -- no --> NX5
164200```
165201
166202## Vague Clarification Loop (System3 <-> System5)
@@ -185,61 +221,64 @@ sequenceDiagram
185221- Task creation starts from an initiative assignment to System3.
186222- If no tasks exist for the initiative, System3 creates task records.
187223- Newly created tasks start in ` pending ` .
188- - System3 selects the next task and assigns it to System1.
224+ - System3 selects the next pending task, then selects the best-suited System1, then assigns .
189225- On assignment handling, System1 moves the task to ` in_progress ` before execution.
190- - After each task ends in ` approved ` or ` canceled ` , System3 checks for remaining
191- tasks in the same initiative and assigns the next one.
192- - If no tasks remain, System3 sends ` InitiativeReviewMessage ` to System4 for
193- initiative review and next-initiative selection.
226+ - After each ` approved ` or ` canceled ` outcome , System3 checks initiative task states:
227+ - if pending tasks exist, assign the next pending task
228+ - if no pending tasks but non-terminal tasks exist, wait
229+ - if all tasks are terminal ( ` approved|canceled ` ), send ` InitiativeReviewMessage ` to System4
194230
195231## Status Semantics
196- - ` pending ` : backlog state for an already- defined task, ready to be assigned .
232+ - ` pending ` : backlog state for a defined task, ready for assignment .
197233- ` in_progress ` : task is actively being executed by System1.
198234- ` blocked ` : System1 could not complete task with current context/capability.
199- - ` completed ` : System1 returned done-result; waiting for/under review outcome .
235+ - ` completed ` : System1 returned done-result; waiting for/under policy review .
200236- ` approved ` : completed output satisfied policies; terminal success.
201- - ` rejected ` : completed output failed policy review; requires rework or cancellation decision .
202- - ` canceled ` : terminal stop state when work should not continue on this task.
237+ - ` rejected ` : completed output failed policy review; must be archived and replaced .
238+ - ` canceled ` : terminal stop state for that specific task attempt .
203239
204240## Review Contract
205241- Review-eligible statuses are ` completed ` and ` blocked ` .
206- - If a ` TaskReviewMessage ` is received for any other status, System3 should
207- treat it as an internal error, route it to System5, reset task status to
208- ` pending ` , and continue with assignment.
242+ - If a ` TaskReviewMessage ` is received for any other status:
243+ - System3 sends ` InternalErrorMessage ` to System5
244+ - System3 resets task to ` pending ` and reassigns (best System1 reselected)
245+ - auto-retry is capped at 3 attempts
246+ - after cap is reached, System3 keeps escalation-only behavior and does not auto-retry
209247- ` completed ` path:
210248 - all cases ` Satisfied ` -> ` approved `
211249 - any case ` Vague ` -> remain ` completed ` and request clarification/review retry
212250 - no vague and at least one ` Violated ` -> ` rejected `
213251- ` blocked ` path:
214252 - System3 executes blocked-resolution flow (research/modify/restart)
215- - if blocked-resolution determines System1 is not equipped, System3 sends
216- a remediation request to System5 and continues via ` System5 remediation outcome `
217- - task can return to ` in_progress ` or end as ` canceled `
253+ - if blocked-resolution determines System1 is not equipped, System3 sends a remediation request to System5
254+ - result is either resumed execution (` pending ` -> reassigned) or ` canceled `
218255
219256## Rejected Task Flow
220- After a task is ` rejected ` , handling should be:
221- - choose one of two paths:
222- - existing System1 can solve it with improved information/prompt
223- - System1 change is required (capability/config/profile remediation via System5)
224-
225- If replacement work is created, the flow should:
226- - compile structured rejection evidence from case judgements and execution traces
227- - request System5 remediation before replacement assignment
228- - System5 may update current System1 config/skills
229- - or authorize a better-equipped System1 profile
257+ After a task is ` rejected ` , handling is always replacement-based:
258+ - original rejected task is moved to ` canceled `
259+ - a replacement task is created in the same initiative
260+ - replacement starts as ` pending `
261+ - replacement does not inherit assignee; System3 always reselects best System1
262+
263+ Decision split before replacement assignment:
264+ - existing System1 can pass with better information/prompt
265+ - System1 change is required
266+
267+ If System1 change is required:
268+ - System3 compiles structured rejection evidence (cases + execution traces)
269+ - System3 sends remediation request to System5
270+ - System5 may update System1 config/skills or authorize a new System1 profile
230271- only System5 escalates to user when no viable remediation exists
231- - move the original task to ` canceled `
232- - link replacement task IDs on the original via ` follow_up_task_ids `
233- - route into the task-creation path (` System3 creates task records ` )
234272
235- ## Follow-Up Task Linking
236- - Field : ` tasks.follow_up_task_ids ` (JSON list of integer task IDs)
237- - Purpose: lineage between original task and replacement/follow-up tasks
273+ ## Task Attempt Lineage
274+ - Forward link on original task : ` tasks.follow_up_task_ids ` (JSON list of task IDs)
275+ - Reverse link on replacement task: ` tasks.replaces_task_id ` (single task ID)
238276- Expected usage:
239- - when a rejected task is replaced, append the new task ID(s) to the original
240- - keep the original task as historical record (` rejected ` or ` canceled ` )
277+ - when a rejected task is replaced, append replacement id to original ` follow_up_task_ids `
278+ - set replacement ` replaces_task_id ` to original task id
279+ - keep all attempts as immutable historical records
241280
242281## Discussion Topics
243- Use this section to align desired behavior before further code changes:
244- - Should System3 always create follow-up tasks on cancellation, or only for selected rejection scenarios?
245- - Should initiative progression depend on all tasks being terminal ( ` approved|canceled ` )?
282+ Use this section to align remaining details before code changes:
283+ - Exact message schemas/payloads for replacement creation and remediation outcomes
284+ - Whether ` NX5 ` should be purely passive wait or publish an explicit heartbeat/monitor event
0 commit comments