@mamdouh-aboammar/agentic-workflow 1.2.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.
- package/.claude-plugin/plugin.json +10 -0
- package/.codex-plugin/plugin.json +13 -0
- package/.skills.json +19 -0
- package/AGENTS.md +1344 -0
- package/CLAUDE.md +178 -0
- package/GEMINI.md +102 -0
- package/LICENSE +21 -0
- package/README.md +350 -0
- package/SKILL.md +132 -0
- package/bin/agentic-hooks.sh +79 -0
- package/bin/cli.js +1060 -0
- package/core/__init__.py +52 -0
- package/core/ai_evaluator.py +117 -0
- package/core/autopilot_engine.py +368 -0
- package/core/clean_code_guard.py +188 -0
- package/core/engine_py/__init__.py +29 -0
- package/core/engine_py/agent_worker.py +136 -0
- package/core/engine_py/decider.py +150 -0
- package/core/engine_py/energy.py +45 -0
- package/core/engine_py/event_bus.py +63 -0
- package/core/engine_py/executor.py +186 -0
- package/core/engine_py/models.py +193 -0
- package/core/engine_py/queue.py +314 -0
- package/core/engine_py/runner.py +116 -0
- package/core/engine_py/system_workers.py +70 -0
- package/core/engine_py/toon_adapter.py +586 -0
- package/core/engine_py/verification_controller.py +208 -0
- package/core/engine_py/worker.py +167 -0
- package/core/engine_spec/event_schema.json +65 -0
- package/core/engine_spec/example_workflow.yaml +73 -0
- package/core/engine_spec/workflow_schema.json +127 -0
- package/core/hooks/__init__.py +29 -0
- package/core/hooks/adapters/__init__.py +25 -0
- package/core/hooks/adapters/claude_adapter.py +83 -0
- package/core/hooks/adapters/cli_agent_adapter.py +82 -0
- package/core/hooks/adapters/codex_adapter.py +78 -0
- package/core/hooks/adapters/cursor_adapter.py +73 -0
- package/core/hooks/adapters/gemini_adapter.py +93 -0
- package/core/hooks/adapters/homebrew_adapter.py +69 -0
- package/core/hooks/adapters/mcp_proxy.py +133 -0
- package/core/hooks/adapters/shell_adapter.py +65 -0
- package/core/hooks/dispatcher.py +118 -0
- package/core/hooks/policy_engine.py +375 -0
- package/core/hooks/session_end.py +141 -0
- package/core/hooks/types.py +147 -0
- package/core/integrations/__init__.py +28 -0
- package/core/integrations/installer.py +225 -0
- package/core/integrations/lifecycle_director.py +175 -0
- package/core/integrations/registry.py +105 -0
- package/core/multi_agent_system.py +164 -0
- package/core/skills_indexer.py +742 -0
- package/core/system/__init__.py +25 -0
- package/core/system/announcements.py +72 -0
- package/core/system/dependencies.py +69 -0
- package/core/system/doctor.py +171 -0
- package/core/system/health.py +144 -0
- package/core/system/installer.py +137 -0
- package/core/system/notifications.py +97 -0
- package/core/system/refresher.py +110 -0
- package/core/system/updater.py +167 -0
- package/core/system/version_tracker.py +65 -0
- package/docs/architecture_plan.md +7 -0
- package/docs/guides/failure-recovery.md +714 -0
- package/docs/implementation_summary.md +10 -0
- package/docs/protocols/autopilot-execution.md +148 -0
- package/docs/protocols/code-change-protocol.md +49 -0
- package/docs/protocols/context-preservation-detail.md +114 -0
- package/docs/protocols/quality-gates.md +110 -0
- package/docs/protocols/ulw-mode.md +60 -0
- package/docs/research_findings.md +10 -0
- package/docs/solutions/autonomous-autopilot-engine-architecture.md +38 -0
- package/install.sh +111 -0
- package/marketplace.json +37 -0
- package/package.json +81 -0
- package/skills/agentic-workflow/SKILL.md +132 -0
- package/skills/agentic-workflow/skill-spec.json +100 -0
- package/soul.md +445 -0
- package/src/engine_ts/decider.ts +186 -0
- package/src/engine_ts/event-bus.ts +57 -0
- package/src/engine_ts/executor.ts +262 -0
- package/src/engine_ts/index.ts +12 -0
- package/src/engine_ts/queue.ts +93 -0
- package/src/engine_ts/runner.ts +108 -0
- package/src/engine_ts/skills-indexer.ts +264 -0
- package/src/engine_ts/toon-adapter.ts +91 -0
- package/src/engine_ts/types.ts +134 -0
- package/src/engine_ts/verification-controller.ts +204 -0
- package/src/engine_ts/worker.ts +280 -0
- package/src/hooks/adapters/claude-adapter.ts +54 -0
- package/src/hooks/adapters/cli-agent-adapter.ts +46 -0
- package/src/hooks/adapters/codex-adapter.ts +69 -0
- package/src/hooks/adapters/cursor-adapter.ts +60 -0
- package/src/hooks/adapters/gemini-adapter.ts +71 -0
- package/src/hooks/adapters/homebrew-adapter.ts +36 -0
- package/src/hooks/adapters/mcp-proxy.ts +66 -0
- package/src/hooks/adapters/shell-adapter.ts +42 -0
- package/src/hooks/dispatcher.ts +113 -0
- package/src/hooks/index.ts +16 -0
- package/src/hooks/policy-engine.ts +376 -0
- package/src/hooks/session-end.ts +125 -0
- package/src/hooks/types.ts +61 -0
- package/src/index.d.ts +34 -0
- package/src/index.ts +23 -0
- package/src/integrations/index.ts +7 -0
- package/src/integrations/installer.ts +208 -0
- package/src/integrations/lifecycle-director.ts +139 -0
- package/src/integrations/registry.ts +82 -0
- package/src/system/announcements.ts +143 -0
- package/src/system/dependencies.ts +176 -0
- package/src/system/doctor.ts +374 -0
- package/src/system/health.ts +270 -0
- package/src/system/index.ts +14 -0
- package/src/system/installer.ts +262 -0
- package/src/system/notifications.ts +180 -0
- package/src/system/refresher.ts +207 -0
- package/src/system/types.ts +268 -0
- package/src/system/updater.ts +219 -0
- package/src/system/version-tracker.ts +137 -0
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
# Failure Recovery Guide — Orchestrator Perspective
|
|
2
|
+
|
|
3
|
+
This guide provides comprehensive instructions for handling workflow failures and implementing Sisyphus Persistence (I-1) recovery strategies.
|
|
4
|
+
|
|
5
|
+
**Audience**: Orchestrator agents executing workflows
|
|
6
|
+
**Scope**: (human) and (team) stage failures, verification gate failures, sub-agent invocation failures
|
|
7
|
+
**Related**: `docs/protocols/ulw-mode.md` (I-1 Sisyphus Persistence), `docs/protocols/quality-gates.md` (verification failures)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Part 1: Failure Detection & Classification
|
|
12
|
+
|
|
13
|
+
### 1.1 Failure Detection Points
|
|
14
|
+
|
|
15
|
+
Failures can occur at 6 critical points in workflow execution:
|
|
16
|
+
|
|
17
|
+
| Detection Point | Trigger | Severity |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| **Stage execution** | Deliverable generation incomplete/incorrect | Variable (P1-P4) |
|
|
20
|
+
| **L0 Anti-Skip Guard** | Stage skipped or step mismatch detected | CRITICAL (exit workflow) |
|
|
21
|
+
| **L1 Verification Gate** | Verification criteria not met (status=FAIL) | HIGH (retry or escalate) |
|
|
22
|
+
| **L1.5 pACS Self-Rating** | pACS score below threshold (<50) | MEDIUM (enhanced scrutiny) |
|
|
23
|
+
| **L2 Calibration** | Team Lead rejects aggregated pACS score | HIGH (retry or escalate) |
|
|
24
|
+
| **Sub-agent invocation** | Fork decision validation fails, sub-agent reports failure | HIGH (retry with alternative approach) |
|
|
25
|
+
|
|
26
|
+
### 1.2 Failure Classification
|
|
27
|
+
|
|
28
|
+
All failures fall into three categories for Sisyphus Persistence:
|
|
29
|
+
|
|
30
|
+
#### **A. Transient Failures** (Retry with Same Approach)
|
|
31
|
+
- Network timeout in agent invocation → Retry immediately (same approach)
|
|
32
|
+
- Task dependency temporarily blocked → Retry after dependency resolves
|
|
33
|
+
- Verification criteria marginally unmet → Minimal adjustment + retry same approach
|
|
34
|
+
|
|
35
|
+
**Recovery Strategy**: Immediate retry (≤3 times) with no approach change. If all fail → escalate.
|
|
36
|
+
|
|
37
|
+
#### **B. Logic/Design Failures** (Retry with Alternative Approach)
|
|
38
|
+
- Verification criteria fundamentally unmet (e.g., "Missing section X") → Redesign output structure
|
|
39
|
+
- pACS score RED zone (<50) → Revisit logic; generate alternative reasoning
|
|
40
|
+
- Sub-agent contradiction (e.g., @reviewer rejects @translator output) → Adjust input/assumptions
|
|
41
|
+
|
|
42
|
+
**Recovery Strategy**: Analyze root cause → select alternative approach → retry (max 3 approaches).
|
|
43
|
+
|
|
44
|
+
#### **C. Resource/External Failures** (Escalate)
|
|
45
|
+
- API rate limit exhausted → Escalate to Team Lead
|
|
46
|
+
- Insufficient context/information to resolve → Escalate to Team Lead
|
|
47
|
+
- Unresolvable contradiction (e.g., both @reviewer and @fact-checker reject same output) → Escalate
|
|
48
|
+
|
|
49
|
+
**Recovery Strategy**: Report inability with specific reason → escalate to Team Lead or user.
|
|
50
|
+
|
|
51
|
+
### 1.3 Root Cause Analysis
|
|
52
|
+
|
|
53
|
+
When a failure occurs:
|
|
54
|
+
|
|
55
|
+
1. **Collect failure context**:
|
|
56
|
+
- Error message (full stack trace if available)
|
|
57
|
+
- Deliverable path (if partially generated)
|
|
58
|
+
- Verification criteria that failed (if L1 failure)
|
|
59
|
+
- pACS score breakdown (if pACS failure)
|
|
60
|
+
- Time since stage start
|
|
61
|
+
- Previous retry attempts (count + approaches tried)
|
|
62
|
+
|
|
63
|
+
2. **Classify as Transient/Logic/Resource**:
|
|
64
|
+
- Transient: Time-bound (timeout, temporary block)
|
|
65
|
+
- Logic: Content-bound (missing section, contradictory feedback)
|
|
66
|
+
- Resource: System-bound (rate limit, insufficient data)
|
|
67
|
+
|
|
68
|
+
3. **Record classification in SOT**:
|
|
69
|
+
```yaml
|
|
70
|
+
steps[step-N]:
|
|
71
|
+
failures:
|
|
72
|
+
- attempt: 1
|
|
73
|
+
timestamp: "2026-04-24T11:00:00Z"
|
|
74
|
+
classification: "logic" # or "transient" / "resource"
|
|
75
|
+
root_cause: "Missing assumption in section 2.1"
|
|
76
|
+
approach_used: "approach-A"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Part 2: Sisyphus Persistence — 3 Retry Strategy
|
|
82
|
+
|
|
83
|
+
### 2.1 Retry Budget & Attempt Sequencing
|
|
84
|
+
|
|
85
|
+
When **I-1 Sisyphus Persistence** is active (ULW mode):
|
|
86
|
+
|
|
87
|
+
- **Maximum attempts per stage**: 3
|
|
88
|
+
- **Each attempt must use different approach**
|
|
89
|
+
- **Tracking location**: SOT `steps[step-N].retry_history[]`
|
|
90
|
+
|
|
91
|
+
#### Retry Sequencing:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
┌─────────────────────────────────────────────────────────┐
|
|
95
|
+
│ STAGE START: (human) or (team) stage execution │
|
|
96
|
+
└──────────────────────┬──────────────────────────────────┘
|
|
97
|
+
│
|
|
98
|
+
┌──────────────┴──────────────┐
|
|
99
|
+
│ Attempt 1: Approach A │
|
|
100
|
+
│ (Primary, most direct) │
|
|
101
|
+
└──────────┬───────────────────┘
|
|
102
|
+
│ PASS → ADVANCE
|
|
103
|
+
│ FAIL → Classify
|
|
104
|
+
┌──────────┴──────────────────┐
|
|
105
|
+
│ Attempt 2: Approach B │
|
|
106
|
+
│ (Alternative 1: Modify │
|
|
107
|
+
│ assumptions/structure) │
|
|
108
|
+
└──────────┬───────────────────┘
|
|
109
|
+
│ PASS → ADVANCE
|
|
110
|
+
│ FAIL → Classify
|
|
111
|
+
┌──────────┴──────────────────┐
|
|
112
|
+
│ Attempt 3: Approach C │
|
|
113
|
+
│ (Alternative 2: Radical │
|
|
114
|
+
│ redesign/pivot) │
|
|
115
|
+
└──────────┬───────────────────┘
|
|
116
|
+
│ PASS → ADVANCE
|
|
117
|
+
│ FAIL → Classify (Resource?)
|
|
118
|
+
┌──────────┴──────────────────┐
|
|
119
|
+
│ All 3 attempts exhausted │
|
|
120
|
+
│ ESCALATE to Team Lead │
|
|
121
|
+
└─────────────────────────────┘
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2.2 Approach Definition by Failure Type
|
|
125
|
+
|
|
126
|
+
#### **For Transient Failures** (e.g., timeout):
|
|
127
|
+
- Approach A: Standard retry (same parameters)
|
|
128
|
+
- Approach B: Extended timeout + logging
|
|
129
|
+
- Approach C: Alternative invocation method (e.g., direct vs. sub-agent)
|
|
130
|
+
|
|
131
|
+
#### **For Logic Failures** (e.g., "Missing section"):
|
|
132
|
+
- Approach A: Generate output with standard template
|
|
133
|
+
- Approach B: Simplify template; focus on core sections only
|
|
134
|
+
- Approach C: Completely different structure (e.g., Q&A format instead of narrative)
|
|
135
|
+
|
|
136
|
+
#### **For pACS Failures** (YELLOW/RED zone):
|
|
137
|
+
- Approach A: Add detail to weak dimension (if YELLOW)
|
|
138
|
+
- Approach B: Restructure for clarity (if Logic weak)
|
|
139
|
+
- Approach C: Request additional input/constraints from Team Lead (if RED + transient)
|
|
140
|
+
|
|
141
|
+
#### **For Sub-agent Failures** (@translator, @reviewer, @fact-checker):
|
|
142
|
+
- Approach A: Re-invoke with same parameters (transient?)
|
|
143
|
+
- Approach B: Adjust fork context (glossary, previous output) + retry
|
|
144
|
+
- Approach C: Alternative sub-agent (e.g., @reviewer instead of @fact-checker) or human fallback
|
|
145
|
+
|
|
146
|
+
### 2.3 Attempt Tracking & Decision Logging
|
|
147
|
+
|
|
148
|
+
For each attempt, record in SOT:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
steps[step-N]:
|
|
152
|
+
retry_history:
|
|
153
|
+
- attempt: 1
|
|
154
|
+
approach: "approach-A" # Human-readable label
|
|
155
|
+
timestamp_start: "2026-04-24T11:00:00Z"
|
|
156
|
+
timestamp_end: "2026-04-24T11:05:00Z"
|
|
157
|
+
output_path: "step-N-attempt-1.md"
|
|
158
|
+
verification_status: "FAIL"
|
|
159
|
+
pacs_score: 45
|
|
160
|
+
failure_reason: "Missing assumption in section 2.1"
|
|
161
|
+
- attempt: 2
|
|
162
|
+
approach: "approach-B" # Modified assumptions
|
|
163
|
+
timestamp_start: "2026-04-24T11:05:00Z"
|
|
164
|
+
timestamp_end: "2026-04-24T11:10:00Z"
|
|
165
|
+
output_path: "step-N-attempt-2.md"
|
|
166
|
+
verification_status: "PASS"
|
|
167
|
+
pacs_score: 78
|
|
168
|
+
completion_timestamp: "2026-04-24T11:10:00Z"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Log decision to Decision Log:
|
|
172
|
+
|
|
173
|
+
```markdown
|
|
174
|
+
## Stage Recovery: step-N (Attempt 2/3 — Approach B)
|
|
175
|
+
|
|
176
|
+
**Previous Attempt**: Attempt 1 failed with "Missing assumption in section 2.1"
|
|
177
|
+
|
|
178
|
+
**Approach Change**: Modified section 2.1 assumptions based on previous feedback
|
|
179
|
+
|
|
180
|
+
**Execution Time**: 5 minutes (11:05–11:10)
|
|
181
|
+
|
|
182
|
+
**Result**: ✅ PASS (pACS 78/100)
|
|
183
|
+
|
|
184
|
+
**Decision**: Stage completed after 2 attempts. Proceed to next stage.
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Part 3: Failure Recovery Workflows
|
|
190
|
+
|
|
191
|
+
### 3.1 (human) Stage Failure Recovery
|
|
192
|
+
|
|
193
|
+
**Flow**:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
(human) Stage Start (e.g., Research)
|
|
197
|
+
│
|
|
198
|
+
├→ Orchestrator invokes Agent(stage_spec)
|
|
199
|
+
│
|
|
200
|
+
├→ Agent generates deliverable
|
|
201
|
+
│
|
|
202
|
+
├→ L0 Anti-Skip Guard: Check step matches expected step
|
|
203
|
+
│ └─ FAIL? → Stage failed. Exit workflow (fatal error).
|
|
204
|
+
│
|
|
205
|
+
├→ L1 Verification Gate: Check deliverable against criteria
|
|
206
|
+
│ └─ FAIL? → Attempt recovery (see 3.1.1)
|
|
207
|
+
│ └─ PASS? → Proceed to L1.5
|
|
208
|
+
│
|
|
209
|
+
├→ L1.5 pACS Self-Rating: Agent rates own output
|
|
210
|
+
│ └─ RED (<50)? → Enhanced scrutiny (see 3.1.2)
|
|
211
|
+
│ └─ YELLOW (50-69)? → Proceed with caution
|
|
212
|
+
│ └─ GREEN (≥70)? → Proceed normally
|
|
213
|
+
│
|
|
214
|
+
├→ Translation Fork (if configured): @translator invokes
|
|
215
|
+
│ └─ FAIL? → Attempt recovery (see 3.1.3)
|
|
216
|
+
│ └─ PASS? → Continue
|
|
217
|
+
│
|
|
218
|
+
├→ Review Fork (if configured): @reviewer/@fact-checker invokes
|
|
219
|
+
│ └─ FAIL? → Attempt recovery (see 3.1.3)
|
|
220
|
+
│ └─ PASS? → Continue
|
|
221
|
+
│
|
|
222
|
+
└→ Advance to next stage
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### **3.1.1 L1 Verification Failure Recovery**
|
|
226
|
+
|
|
227
|
+
**Trigger**: `verification[step-N].status == "FAIL"`
|
|
228
|
+
|
|
229
|
+
**Recovery Steps**:
|
|
230
|
+
|
|
231
|
+
1. **Classify failure** (section 1.3)
|
|
232
|
+
- Is this transient (timeout), logic (missing section), or resource (insufficient info)?
|
|
233
|
+
|
|
234
|
+
2. **If Transient**: Retry same approach (Attempt 2)
|
|
235
|
+
- Orchestrator: Reset any time-dependent state
|
|
236
|
+
- Invoke Agent again with same stage spec
|
|
237
|
+
- Proceed to L1 verification
|
|
238
|
+
|
|
239
|
+
3. **If Logic**: Modify stage spec + retry with Approach B
|
|
240
|
+
- Analyze verification failure reason
|
|
241
|
+
- Modify stage spec with constraints/guidance (e.g., "Must include section X with explicit assumptions")
|
|
242
|
+
- Invoke Agent again
|
|
243
|
+
- Proceed to L1 verification
|
|
244
|
+
|
|
245
|
+
4. **If Resource**: Escalate
|
|
246
|
+
- Report: "Cannot resolve verification failure after 2 attempts. Reason: [specific]"
|
|
247
|
+
- Escalate to Team Lead
|
|
248
|
+
|
|
249
|
+
5. **After 3 Attempts**: All failed?
|
|
250
|
+
- Record: `steps[step-N].completion_status = "BLOCKED"`
|
|
251
|
+
- Escalate to Team Lead with full retry_history
|
|
252
|
+
|
|
253
|
+
#### **3.1.2 pACS RED Zone (Score <50) Recovery**
|
|
254
|
+
|
|
255
|
+
**Trigger**: `pacs[step-N].current_step_score < 50` (RED zone)
|
|
256
|
+
|
|
257
|
+
**Mandatory Action**: Do NOT proceed. Investigate root cause.
|
|
258
|
+
|
|
259
|
+
1. **Analyze pACS dimensions**:
|
|
260
|
+
- Which dimension is lowest (F, C, L)?
|
|
261
|
+
- Is there a consistent weakness pattern?
|
|
262
|
+
|
|
263
|
+
2. **Approach B — Enhanced Scrutiny**:
|
|
264
|
+
- Re-run Stage with additional constraints (e.g., "Explicitly state all assumptions")
|
|
265
|
+
- Focus on weak dimension (e.g., if Logic weak: "Validate each inference step")
|
|
266
|
+
|
|
267
|
+
3. **If Still RED**: Escalate
|
|
268
|
+
- Reason: "pACS RED zone persists after 2 attempts"
|
|
269
|
+
- Request: Team Lead guidance on stage design modification
|
|
270
|
+
|
|
271
|
+
#### **3.1.3 Sub-agent Failure Recovery** (@translator, @reviewer, @fact-checker)
|
|
272
|
+
|
|
273
|
+
**Trigger**: Sub-agent task FAIL or returns error
|
|
274
|
+
|
|
275
|
+
**Recovery Steps**:
|
|
276
|
+
|
|
277
|
+
1. **Classify failure type**:
|
|
278
|
+
- @translator fails: Missing glossary entry? Bad source content?
|
|
279
|
+
- @reviewer rejects: Logic weak? Assumptions unstated?
|
|
280
|
+
- @fact-checker rejects: Citation missing? Claim unverified?
|
|
281
|
+
|
|
282
|
+
2. **Approach B — Adjust Fork Context**:
|
|
283
|
+
- If @translator: Add glossary entry + retry
|
|
284
|
+
- If @reviewer: Strengthen logic section + retry
|
|
285
|
+
- If @fact-checker: Add citations + retry
|
|
286
|
+
|
|
287
|
+
3. **Approach C — Alternative Sub-agent**:
|
|
288
|
+
- @translator → Fallback to human-in-loop OR retry with explicit glossary pre-creation
|
|
289
|
+
- @reviewer → Escalate to Team Lead for manual L2 review
|
|
290
|
+
- @fact-checker → Retry with @reviewer instead (less strict)
|
|
291
|
+
|
|
292
|
+
4. **If All Approaches Fail**: Escalate
|
|
293
|
+
- Create Decision Log entry: "Sub-agent [name] failure — unresolved after 3 approaches"
|
|
294
|
+
- Escalate to Team Lead
|
|
295
|
+
|
|
296
|
+
### 3.2 (team) Stage Failure Recovery
|
|
297
|
+
|
|
298
|
+
**Flow**:
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
(team) Stage Start (e.g., "Team Coordination")
|
|
302
|
+
│
|
|
303
|
+
├→ Orchestrator: TeamCreate → active_team created
|
|
304
|
+
│
|
|
305
|
+
├→ Orchestrator: TaskCreate for each stage requirement
|
|
306
|
+
│
|
|
307
|
+
├→ Teammates: Execute assigned tasks (in parallel)
|
|
308
|
+
│ └─ Failures handled per-task
|
|
309
|
+
│
|
|
310
|
+
├→ Team Lead: L1 verification per task (TaskUpdate + SendMessage feedback)
|
|
311
|
+
│ └─ Task L1 FAIL? → SendMessage to teammate with retry guidance
|
|
312
|
+
│ └─ Task L1 PASS? → Record in SOT
|
|
313
|
+
│
|
|
314
|
+
├→ Team Lead: L1.5 pACS self-rating collection
|
|
315
|
+
│ └─ RED zone? → Enhanced scrutiny on that dimension
|
|
316
|
+
│
|
|
317
|
+
├→ Team Lead: L2 comprehensive verification (stage-level)
|
|
318
|
+
│ └─ L2 FAIL? → Stage failure recovery (see 3.2.1)
|
|
319
|
+
│ └─ L2 PASS? → Proceed
|
|
320
|
+
│
|
|
321
|
+
└→ Orchestrator: TeamDelete → clean up active_team
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
#### **3.2.1 Team Stage L2 Failure Recovery**
|
|
325
|
+
|
|
326
|
+
**Trigger**: Team Lead `verification[stage-N].status == "FAIL"` after L1 checks
|
|
327
|
+
|
|
328
|
+
**Recovery Steps**:
|
|
329
|
+
|
|
330
|
+
1. **Identify failing task(s)**:
|
|
331
|
+
- Team Lead reviews task_verification[] records
|
|
332
|
+
- Which task(s) have issues? (L1 PASS but L2 FAIL)
|
|
333
|
+
|
|
334
|
+
2. **Approach B — Task Rerun**:
|
|
335
|
+
- SendMessage to specific teammate: "[task-name] needs revision for [specific reason]"
|
|
336
|
+
- Teammate reruns task with guidance
|
|
337
|
+
- Team Lead re-verifies L1
|
|
338
|
+
|
|
339
|
+
3. **If Task Still Fails**: Escalate or reassign
|
|
340
|
+
- Reassign to different teammate (if available)
|
|
341
|
+
- OR escalate task to Orchestrator (human intervention)
|
|
342
|
+
|
|
343
|
+
4. **After 3 Attempts (per task)**:
|
|
344
|
+
- If critical task: Escalate entire (team) stage
|
|
345
|
+
- If non-critical: Skip task, mark as "Deferred" (note in SOT)
|
|
346
|
+
|
|
347
|
+
5. **If L2 Still FAIL**:
|
|
348
|
+
- Record: `steps[step-N].completion_status = "BLOCKED"`
|
|
349
|
+
- Escalate to user with specific failures + team lead recommendation
|
|
350
|
+
|
|
351
|
+
#### **3.2.2 Handling Task Dependency Failures**
|
|
352
|
+
|
|
353
|
+
**Trigger**: Task B blocked because Task A (which it depends on) failed
|
|
354
|
+
|
|
355
|
+
**Recovery**:
|
|
356
|
+
|
|
357
|
+
1. **Option A** (Short-term): Hold Task B, retry Task A with Approach B
|
|
358
|
+
- If Task A succeeds → Task B proceeds
|
|
359
|
+
- If Task A fails 3× → Escalate entire (team) stage
|
|
360
|
+
|
|
361
|
+
2. **Option B** (Redesign): Modify Task B to not depend on Task A
|
|
362
|
+
- Requires Team Lead design modification
|
|
363
|
+
- Escalate to Team Lead
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Part 4: SOT State Management During Retries
|
|
368
|
+
|
|
369
|
+
### 4.1 Snapshot & Rollback Pattern
|
|
370
|
+
|
|
371
|
+
When retrying a failed stage:
|
|
372
|
+
|
|
373
|
+
1. **Capture pre-retry snapshot**:
|
|
374
|
+
```yaml
|
|
375
|
+
steps[step-N]:
|
|
376
|
+
state_snapshots:
|
|
377
|
+
- attempt: 1
|
|
378
|
+
snapshot_file: "step-N-attempt-1-snapshot.yaml"
|
|
379
|
+
timestamp: "2026-04-24T11:00:00Z"
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
2. **Execute retry**:
|
|
383
|
+
- Use captured snapshot as baseline
|
|
384
|
+
- Modifications are localized to this attempt
|
|
385
|
+
|
|
386
|
+
3. **On success**: Commit new state to SOT
|
|
387
|
+
- Update `steps[step-N].outputs[attempt-2]`
|
|
388
|
+
- Update `steps[step-N].verification` with new status
|
|
389
|
+
- Record timestamp in `steps[step-N].completion_timestamp`
|
|
390
|
+
|
|
391
|
+
4. **On failure**: Retain snapshot, prepare for Attempt 3
|
|
392
|
+
- Do NOT overwrite `steps[step-N].state_snapshots`
|
|
393
|
+
- Next attempt uses same baseline (or Team Lead provides modified baseline)
|
|
394
|
+
|
|
395
|
+
### 4.2 Decision Log State Reference
|
|
396
|
+
|
|
397
|
+
All retry decisions are logged in Decision Log with reference to SOT:
|
|
398
|
+
|
|
399
|
+
```markdown
|
|
400
|
+
## Retry Decision: step-research, Attempt 2
|
|
401
|
+
|
|
402
|
+
**Reference**: [state.yaml](state.yaml) → `steps[step-research].retry_history[1]`
|
|
403
|
+
|
|
404
|
+
**Classification**: Logic failure (missing assumption in section 2)
|
|
405
|
+
|
|
406
|
+
**Approach**: Approach B — Modified section 2 structure + assumptions
|
|
407
|
+
|
|
408
|
+
**Execution Result**: pACS 78/100 (PASS) — Verified 2026-04-24T11:10:00Z
|
|
409
|
+
|
|
410
|
+
**Decision**: Stage completed. Proceed to next stage.
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## Part 5: Verification Gate Failure Handling
|
|
416
|
+
|
|
417
|
+
### 5.1 Retry Budget for Verification Gates
|
|
418
|
+
|
|
419
|
+
Verification gates have **separate** retry budget from Sisyphus Persistence:
|
|
420
|
+
|
|
421
|
+
| Gate | Base Budget | ULW Budget | Allocation |
|
|
422
|
+
|------|------------|-----------|-----------|
|
|
423
|
+
| L0 (Anti-Skip) | 0 | 0 | Non-retryable (fatal) |
|
|
424
|
+
| L1 (Verification) | 10 | 15 | Per-stage (cumulative across attempts) |
|
|
425
|
+
| L1.5 (pACS) | Implicit | Implicit | Sampled at each L1 pass |
|
|
426
|
+
| L2 (Calibration) | 10 | 15 | Per-stage (Team Lead decision) |
|
|
427
|
+
|
|
428
|
+
**Total for stage**: Up to 15 L1 retrys + 15 L2 retrys under ULW (independent budgets).
|
|
429
|
+
|
|
430
|
+
### 5.2 Escalation Criteria
|
|
431
|
+
|
|
432
|
+
After exhausting retry budget:
|
|
433
|
+
|
|
434
|
+
| Gate | Exhaustion Signal | Escalation Action |
|
|
435
|
+
|------|---|---|
|
|
436
|
+
| L0 | N/A (fatal immediately) | Exit workflow |
|
|
437
|
+
| L1 | 15 consecutive fails | Mark stage BLOCKED, escalate to Team Lead |
|
|
438
|
+
| L1.5 | Repeated RED scores after 2 Sisyphus attempts | Team Lead guidance required |
|
|
439
|
+
| L2 (Team) | 15 fails + teammate reassignments exhausted | Escalate to Orchestrator |
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## Part 6: Team Stage Failure Coordination
|
|
444
|
+
|
|
445
|
+
### 6.1 Teammate Failure Reporting
|
|
446
|
+
|
|
447
|
+
When a teammate fails a task:
|
|
448
|
+
|
|
449
|
+
**Teammate → Team Lead (via SendMessage)**:
|
|
450
|
+
```
|
|
451
|
+
Task: [task-name]
|
|
452
|
+
Status: FAILED (L1 verification)
|
|
453
|
+
Reason: [specific criterion not met]
|
|
454
|
+
Evidence: [error message / verification result]
|
|
455
|
+
Attempt: [1/3]
|
|
456
|
+
|
|
457
|
+
Request: Guidance for next attempt
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Team Lead → Teammate (via SendMessage)**:
|
|
461
|
+
```
|
|
462
|
+
Task: [task-name] — Attempt 2
|
|
463
|
+
|
|
464
|
+
**Feedback**: [Specific guidance on what to change]
|
|
465
|
+
|
|
466
|
+
**Approach**: [Approach B description]
|
|
467
|
+
|
|
468
|
+
**Execution**: [Retry deadline, if applicable]
|
|
469
|
+
|
|
470
|
+
**Success Criteria**: [Modified criteria if Approach B requires changes]
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### 6.2 Handling Contradictory Feedback
|
|
474
|
+
|
|
475
|
+
When teammates disagree (e.g., Teammate A says "Include section X", Teammate B says "Section X is redundant"):
|
|
476
|
+
|
|
477
|
+
1. **Team Lead** identifies contradiction in L1 verification records
|
|
478
|
+
2. **Team Lead** synthesizes guidance:
|
|
479
|
+
```
|
|
480
|
+
Both feedback items are valid in different contexts.
|
|
481
|
+
Approach B: Restructure output to address both concerns.
|
|
482
|
+
[Specific guidance on how to combine]
|
|
483
|
+
```
|
|
484
|
+
3. **Reassign** to teammate with additional context
|
|
485
|
+
4. **If still contradictory**: Escalate to Orchestrator (design flaw in stage requirements)
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Part 7: Example Walkthroughs
|
|
490
|
+
|
|
491
|
+
### 7.1 (human) Stage Failure — Logic Failure + Sisyphus Recovery
|
|
492
|
+
|
|
493
|
+
**Scenario**: Research stage fails L1 verification ("Missing assumptions in section 2")
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
ATTEMPT 1: Research Stage (Approach A)
|
|
497
|
+
├─ Agent generates research output (standard template)
|
|
498
|
+
├─ L1 Verification: FAIL — "Section 2 lacks explicit assumptions"
|
|
499
|
+
├─ Classification: Logic failure
|
|
500
|
+
├─ Time taken: 5 minutes
|
|
501
|
+
└─ Decision: Retry with Approach B
|
|
502
|
+
|
|
503
|
+
ATTEMPT 2: Research Stage (Approach B)
|
|
504
|
+
├─ Orchestrator modifies stage spec:
|
|
505
|
+
│ "Include explicit 'Assumptions' subsection in Section 2"
|
|
506
|
+
├─ Agent generates output with modified structure
|
|
507
|
+
├─ L1 Verification: PASS (all criteria met)
|
|
508
|
+
├─ L1.5 pACS: 78/100 (GREEN zone)
|
|
509
|
+
├─ Translation fork: @translator succeeds
|
|
510
|
+
├─ Review fork: @reviewer approves (pACS 82/100)
|
|
511
|
+
├─ Time taken: 5 minutes
|
|
512
|
+
└─ Result: STAGE COMPLETED
|
|
513
|
+
|
|
514
|
+
SOT recorded:
|
|
515
|
+
steps[step-research]:
|
|
516
|
+
retry_history:
|
|
517
|
+
- attempt: 1
|
|
518
|
+
approach: "approach-A"
|
|
519
|
+
status: "FAIL"
|
|
520
|
+
failure_reason: "Missing assumptions in section 2"
|
|
521
|
+
- attempt: 2
|
|
522
|
+
approach: "approach-B"
|
|
523
|
+
status: "PASS"
|
|
524
|
+
pacs_score: 82
|
|
525
|
+
|
|
526
|
+
Decision Log:
|
|
527
|
+
## Research Stage Recovery (Attempt 2 SUCCESS)
|
|
528
|
+
Approach B modifications (explicit Assumptions subsection) resolved section 2 weakness.
|
|
529
|
+
Stage completed within Sisyphus budget. Proceed to Planning stage.
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### 7.2 (team) Stage Failure — Task Reassignment Recovery
|
|
533
|
+
|
|
534
|
+
**Scenario**: (team) stage Planning has 4 tasks; Task 2 (Analysis) fails L1
|
|
535
|
+
|
|
536
|
+
```
|
|
537
|
+
TASK 1: Literature Review
|
|
538
|
+
├─ Teammate A executes
|
|
539
|
+
├─ L1 Verification: PASS
|
|
540
|
+
└─ Status: COMPLETE
|
|
541
|
+
|
|
542
|
+
TASK 2: Analysis ←← FAILURE
|
|
543
|
+
├─ Teammate B executes
|
|
544
|
+
├─ L1 Verification: FAIL — "Analysis lacks quantitative evidence"
|
|
545
|
+
├─ Attempt: 1/3
|
|
546
|
+
├─ Team Lead sends feedback:
|
|
547
|
+
│ "Approach B: Add 2-3 quantitative case studies to Section 3.2"
|
|
548
|
+
├─ Teammate B reruns task
|
|
549
|
+
├─ L1 Verification: PASS (after revision)
|
|
550
|
+
├─ Status: COMPLETE
|
|
551
|
+
└─ Time spent: 8 minutes
|
|
552
|
+
|
|
553
|
+
TASK 3: Synthesis
|
|
554
|
+
├─ Teammate C executes
|
|
555
|
+
├─ L1 Verification: PASS
|
|
556
|
+
└─ Status: COMPLETE
|
|
557
|
+
|
|
558
|
+
TASK 4: Final Review
|
|
559
|
+
├─ Teammate D executes
|
|
560
|
+
├─ L1 Verification: PASS
|
|
561
|
+
└─ Status: COMPLETE
|
|
562
|
+
|
|
563
|
+
(team) Stage L2 Verification:
|
|
564
|
+
├─ Team Lead reviews all tasks
|
|
565
|
+
├─ pACS aggregation: min(F=85, C=80, L=78) = 78/100
|
|
566
|
+
├─ L2 Verification: PASS
|
|
567
|
+
└─ Result: STAGE COMPLETED
|
|
568
|
+
|
|
569
|
+
SOT recorded:
|
|
570
|
+
steps[step-planning]:
|
|
571
|
+
tasks:
|
|
572
|
+
- task_id: "task-2-analysis"
|
|
573
|
+
status: "PASS"
|
|
574
|
+
attempt_count: 2
|
|
575
|
+
teammate: "Teammate B"
|
|
576
|
+
retry_reason: "Quantitative evidence missing"
|
|
577
|
+
|
|
578
|
+
Decision Log:
|
|
579
|
+
## Planning Stage (team) — Task 2 Recovery
|
|
580
|
+
Task 2 (Analysis) required 1 retry for quantitative evidence.
|
|
581
|
+
All 4 tasks completed within retry budget. Stage L2 passed.
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
---
|
|
585
|
+
|
|
586
|
+
## Part 8: Common Failure Scenarios & Solutions
|
|
587
|
+
|
|
588
|
+
| Scenario | Classification | Recovery Approach | Time |
|
|
589
|
+
|----------|---|---|---|
|
|
590
|
+
| Sub-agent timeout | Transient | Attempt 2: Extend timeout | 1 min |
|
|
591
|
+
| Verification criterion vague | Logic | Attempt 2: Add clarifying constraint | 5 min |
|
|
592
|
+
| pACS logic weak (<50) | Logic | Attempt 2: Strengthen inference steps | 10 min |
|
|
593
|
+
| Teammate conflict (contradiction) | Logic | Team Lead synthesis + rerun | 5 min |
|
|
594
|
+
| API rate limit exhausted | Resource | Escalate to Team Lead (wait time) | N/A |
|
|
595
|
+
| Missing background information | Resource | Escalate to user (input needed) | N/A |
|
|
596
|
+
| Unresolvable sub-agent failure | Resource | Human fallback OR escalate | N/A |
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## Part 9: Troubleshooting & Escalation
|
|
601
|
+
|
|
602
|
+
### 9.1 When to Escalate (Non-Retryable)
|
|
603
|
+
|
|
604
|
+
**DO NOT RETRY** — Escalate immediately:
|
|
605
|
+
|
|
606
|
+
1. **L0 Anti-Skip Guard failure**
|
|
607
|
+
- Stage/step mismatch detected
|
|
608
|
+
- Action: Exit workflow, report to user
|
|
609
|
+
|
|
610
|
+
2. **Resource unavailable** (3 attempts unsuccessful)
|
|
611
|
+
- API rate limit, insufficient data, network down
|
|
612
|
+
- Action: Escalate to Team Lead with context
|
|
613
|
+
|
|
614
|
+
3. **Unresolvable logic contradiction** (3 approaches failed)
|
|
615
|
+
- Both @reviewer and @fact-checker reject same output
|
|
616
|
+
- Multiple teammates give conflicting requirements
|
|
617
|
+
- Action: Escalate to Team Lead for design review
|
|
618
|
+
|
|
619
|
+
4. **Sisyphus budget exhausted**
|
|
620
|
+
- 3 attempts with 3 different approaches all failed
|
|
621
|
+
- Root cause still undiagnosed
|
|
622
|
+
- Action: Report inability + request Team Lead intervention
|
|
623
|
+
|
|
624
|
+
### 9.2 Escalation Message Format
|
|
625
|
+
|
|
626
|
+
When escalating to Team Lead:
|
|
627
|
+
|
|
628
|
+
```markdown
|
|
629
|
+
## Escalation: [Stage Name] — Unresolvable Failure
|
|
630
|
+
|
|
631
|
+
**Stage**: step-[N]-[name]
|
|
632
|
+
**Attempt Count**: 3/3 (Sisyphus budget exhausted)
|
|
633
|
+
|
|
634
|
+
**Approaches Tried**:
|
|
635
|
+
1. Approach A — [Description] → FAIL ([Reason])
|
|
636
|
+
2. Approach B — [Description] → FAIL ([Reason])
|
|
637
|
+
3. Approach C — [Description] → FAIL ([Reason])
|
|
638
|
+
|
|
639
|
+
**Root Cause Analysis**:
|
|
640
|
+
- Classification: [Transient / Logic / Resource]
|
|
641
|
+
- Diagnosis: [Specific finding]
|
|
642
|
+
- Blocker: [What prevents further automatic recovery]
|
|
643
|
+
|
|
644
|
+
**Request**: [Specific action needed from Team Lead]
|
|
645
|
+
- Option 1: [Suggestion A]
|
|
646
|
+
- Option 2: [Suggestion B]
|
|
647
|
+
|
|
648
|
+
**Evidence**: [Link to SOT, Decision Log, output files]
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
## Part 10: Recovery Metrics & Monitoring
|
|
654
|
+
|
|
655
|
+
### 10.1 Tracking Recovery Success
|
|
656
|
+
|
|
657
|
+
Record recovery metrics in SOT:
|
|
658
|
+
|
|
659
|
+
```yaml
|
|
660
|
+
workflow_metrics:
|
|
661
|
+
failure_recovery:
|
|
662
|
+
total_stages: 5
|
|
663
|
+
stages_with_retries: 2
|
|
664
|
+
total_retry_attempts: 3 # Cumulative across all stages
|
|
665
|
+
successful_recoveries: 2 # Attempts that led to PASS
|
|
666
|
+
escalations: 0
|
|
667
|
+
sisyphus_budget_exhaustion: 0
|
|
668
|
+
recovery_rate: "100%" # (successful_recoveries / total_retry_attempts)
|
|
669
|
+
average_retry_time: "6 minutes"
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
### 10.2 Failure Pattern Analysis (Post-Workflow)
|
|
673
|
+
|
|
674
|
+
After workflow completion, Team Lead can analyze:
|
|
675
|
+
|
|
676
|
+
```yaml
|
|
677
|
+
failure_analysis:
|
|
678
|
+
- stage: "step-research"
|
|
679
|
+
failure_type: "logic"
|
|
680
|
+
root_cause: "Missing assumptions"
|
|
681
|
+
approach_success: "approach-B worked"
|
|
682
|
+
lesson: "Stage spec needs explicit 'Assumptions' guidance"
|
|
683
|
+
- stage: "step-planning"
|
|
684
|
+
failure_type: "transient"
|
|
685
|
+
root_cause: "Timeout in sub-agent"
|
|
686
|
+
approach_success: "Simple retry worked"
|
|
687
|
+
lesson: "Sub-agent timeout needs longer deadline"
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
## Summary
|
|
693
|
+
|
|
694
|
+
**Sisyphus Persistence (I-1)** implementation:
|
|
695
|
+
|
|
696
|
+
1. ✅ Detect failure → Classify (Transient/Logic/Resource)
|
|
697
|
+
2. ✅ Select recovery approach (A/B/C based on classification)
|
|
698
|
+
3. ✅ Attempt retry (max 3 total attempts)
|
|
699
|
+
4. ✅ Track in SOT `retry_history[]` + Decision Log
|
|
700
|
+
5. ✅ Escalate on resource failure or budget exhaustion
|
|
701
|
+
6. ✅ For (team) stages, coordinate via Team Lead
|
|
702
|
+
|
|
703
|
+
**Critical NEVER DO**:
|
|
704
|
+
- Never skip classification and just retry
|
|
705
|
+
- Never exceed 3 attempts per stage without escalation
|
|
706
|
+
- Never retry same approach more than once (I-3 violation)
|
|
707
|
+
- Never ignore L0 Anti-Skip Guard failures
|
|
708
|
+
- Never leave task "partially done" without escalation (I-1 violation)
|
|
709
|
+
|
|
710
|
+
**Related Documentation**:
|
|
711
|
+
- `ulw-mode.md` — Full ULW mode specification
|
|
712
|
+
- `quality-gates.md` — Verification gate details
|
|
713
|
+
- `workflow-execution-guide.md` — Stage execution pre-requisites
|
|
714
|
+
- `team-coordination-guide.md` — (team) stage coordination details
|