valent-pipeline 0.2.18 → 0.2.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valent-pipeline",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "v3 multi-agent AI pipeline for software development lifecycle",
5
5
  "type": "module",
6
6
  "bin": {
@@ -69,10 +69,15 @@ Spawn teammates from `agents-manifest.yaml` with:
69
69
 
70
70
  The lead watches the board, not the work. It reads the shared task list to track task states (`pending`, `in_progress`, `completed`). It does NOT read handoff documents to judge quality -- that is the JUDGE gates' job.
71
71
 
72
+ ### Heartbeat Timer
73
+
74
+ At the start of Phase 2, the lead creates a `CronCreate` job that fires every 4 minutes (aligned within Claude's 5-minute prompt cache TTL for near-zero token cost). Each heartbeat triggers a liveness check: call `TaskList`, verify at least one non-Knowledge agent is `in_progress`. If uncompleted tasks exist but no agent is working, the lead diagnoses the deadlock (stale blockers, missed unblocks, dead teammates) and acts. The cron job is deleted during Phase 3 teardown.
75
+
72
76
  ### What the Lead Watches
73
77
 
74
78
  - Task status transitions on the shared task list
75
79
  - Time-in-state for stall detection
80
+ - Heartbeat liveness checks (every 4 minutes via cron timer)
76
81
  - Inbox messages from teammates (escalations, questions, completion notifications)
77
82
 
78
83
  ### What the Lead Does NOT Do
@@ -49,6 +49,7 @@ You receive many message types. Process each by type:
49
49
  | `[DESIGN-COUNCIL]` | Agent requests deliberation. Route to relevant peers or participate. |
50
50
  | `[ESCALATION]` | Agent requests your intervention. Assess and act. |
51
51
  | `[BUG]` | QA-B filed a bug. No action -- QA-B routes directly to devs. Monitor bug count. |
52
+ | `[HEARTBEAT]` | Timer-fired liveness check. Run the Heartbeat Liveness Check procedure below. |
52
53
 
53
54
  Your outbound messages follow the same terse format:
54
55
  - `[SPAWN] Spawning {agent} for {story_id}. Role: {role}. Shared context: {story_output_dir}.`
@@ -431,6 +432,37 @@ Wait for `[KNOWLEDGE-READY]` response before spawning other agents. The Knowledg
431
432
 
432
433
  You watch task status, NOT agent outputs. You do NOT read handoff documents to judge quality -- that is the JUDGE gates' and CRITIC's job.
433
434
 
435
+ ### Heartbeat Setup
436
+
437
+ At the start of Phase 2, create a recurring heartbeat timer using `CronCreate`:
438
+
439
+ ```
440
+ CronCreate:
441
+ cron: "*/4 * * * *"
442
+ prompt: "[HEARTBEAT] Run liveness check — verify at least one agent is actively working."
443
+ recurring: true
444
+ ```
445
+
446
+ This fires every 4 minutes — aligned to stay within Claude's 5-minute prompt cache TTL so each heartbeat is near-zero cost. Store the returned job ID in your tracking state so you can delete it during teardown.
447
+
448
+ ### Heartbeat Liveness Check
449
+
450
+ When you receive a `[HEARTBEAT]` message:
451
+
452
+ 1. Call `TaskList` to get current task states
453
+ 2. Count tasks that are `in_progress` (exclude Knowledge Agent — it is reactive and has no task)
454
+ 3. Count tasks that are NOT `completed` (pending or in_progress)
455
+ 4. Evaluate:
456
+ - **All tasks completed:** All work is done. Proceed to Phase 3 if JUDGE has approved. If JUDGE has not approved yet, check why — JUDGE's task should be `in_progress` or `completed`.
457
+ - **Uncompleted tasks exist AND at least one is `in_progress`:** Healthy. No action needed.
458
+ - **Uncompleted tasks exist AND zero are `in_progress`:** All agents are idle with work remaining. This is the deadlock edge case. Diagnose:
459
+ a. Check which tasks are `pending` and what they are `blockedBy`
460
+ b. Verify the blocking tasks are truly not completed (task state may be stale)
461
+ c. If a blocker is completed but the downstream task was not unblocked, unblock it now
462
+ d. If an agent should be working but is not, send `[CHECK-IN]` to that teammate
463
+ e. If a teammate has died (no response to `[CHECK-IN]`), respawn it using crash recovery (see Phase 4)
464
+ f. If the dependency graph itself is stuck (circular or impossible), escalate to user
465
+
434
466
  ### Stall Detection
435
467
 
436
468
  If a task is `in_progress` longer than `{stall_threshold_minutes}`:
@@ -578,8 +610,8 @@ All agent outputs persist in `{story_output_dir}`: handoff files, reviews, bug r
578
610
  ### Step 3: Verify Story Report
579
611
  JUDGE writes `story-report.md` as part of its SHIP verdict (Step 14b). Verify the file exists in `{story_output_dir}`. If missing (JUDGE error), write it yourself using the template at `.valent-pipeline/templates/story-report.template.md`.
580
612
 
581
- ### Step 4: Tear Down Teammates
582
- Tear down all per-story teammates. Send `shutdown_request` to each individually.
613
+ ### Step 4: Tear Down Heartbeat and Teammates
614
+ Delete the heartbeat cron job using `CronDelete` with the stored job ID. Then tear down all per-story teammates. Send `shutdown_request` to each individually.
583
615
 
584
616
  **Knowledge Agent exception:** If `{is_epic_run}` is true, do NOT tear down the Knowledge Agent. It persists across stories in an epic to avoid respawn overhead (~15-20k tokens per story). It will receive a `[STORY-RESET]` at the next story's kick-off. Tear down Knowledge only at epic completion (final story in the epic).
585
617