valent-pipeline 0.2.18 → 0.2.20

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.20",
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. A separate 4-minute keep-alive ping is created for the Knowledge agent to prevent its prompt cache from expiring during idle periods. Both cron jobs are 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
@@ -50,6 +50,8 @@ Verify ChromaDB at `{chromadb_host}` using v2 API. Base path: `{chromadb_host}/a
50
50
  ## Query Handling
51
51
 
52
52
  For each incoming query:
53
+
54
+ 0. If query is `cache-keepalive`: respond `[KNOWLEDGE-RESPONSE] ack` and stop. This is a prompt cache keep-alive ping — do not search.
53
55
  1. Search correction directives for relevant entries
54
56
  2. Search curated knowledge files for matching sections
55
57
  3. If database connected (SQLite mode): query using the CLI tool and read stdout for results:
@@ -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,50 @@ 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
+ ### Knowledge Cache Keep-Alive
449
+
450
+ Knowledge is a long-lived reactive agent that can sit idle for extended periods between queries. To prevent its prompt cache from expiring (5-minute TTL), create a separate recurring ping:
451
+
452
+ ```
453
+ CronCreate:
454
+ cron: "*/4 * * * *"
455
+ prompt: "[KNOWLEDGE-QUERY] cache-keepalive"
456
+ recurring: true
457
+ ```
458
+
459
+ Send this to Knowledge's inbox (not to Lead). Knowledge will respond with a no-op `[KNOWLEDGE-RESPONSE]` — the round-trip keeps the cache warm. Store the job ID alongside the heartbeat job ID and delete both during teardown.
460
+
461
+ ### Heartbeat Liveness Check
462
+
463
+ When you receive a `[HEARTBEAT]` message:
464
+
465
+ 1. Call `TaskList` to get current task states
466
+ 2. Count tasks that are `in_progress` (exclude Knowledge Agent — it is reactive and has no task)
467
+ 3. Count tasks that are NOT `completed` (pending or in_progress)
468
+ 4. Evaluate:
469
+ - **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`.
470
+ - **Uncompleted tasks exist AND at least one is `in_progress`:** Healthy. No action needed.
471
+ - **Uncompleted tasks exist AND zero are `in_progress`:** All agents are idle with work remaining. This is the deadlock edge case. Diagnose:
472
+ a. Check which tasks are `pending` and what they are `blockedBy`
473
+ b. Verify the blocking tasks are truly not completed (task state may be stale)
474
+ c. If a blocker is completed but the downstream task was not unblocked, unblock it now
475
+ d. If an agent should be working but is not, send `[CHECK-IN]` to that teammate
476
+ e. If a teammate has died (no response to `[CHECK-IN]`), respawn it using crash recovery (see Phase 4)
477
+ f. If the dependency graph itself is stuck (circular or impossible), escalate to user
478
+
434
479
  ### Stall Detection
435
480
 
436
481
  If a task is `in_progress` longer than `{stall_threshold_minutes}`:
@@ -578,8 +623,8 @@ All agent outputs persist in `{story_output_dir}`: handoff files, reviews, bug r
578
623
  ### Step 3: Verify Story Report
579
624
  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
625
 
581
- ### Step 4: Tear Down Teammates
582
- Tear down all per-story teammates. Send `shutdown_request` to each individually.
626
+ ### Step 4: Tear Down Heartbeat and Teammates
627
+ Delete the heartbeat and Knowledge cache keep-alive cron jobs using `CronDelete` with their stored job IDs. Then tear down all per-story teammates. Send `shutdown_request` to each individually.
583
628
 
584
629
  **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
630
 
@@ -665,14 +710,14 @@ Read each orchestration step file in sequence:
665
710
 
666
711
  1. `.valent-pipeline/steps/orchestration/sprint-init.md` — compute velocity, resolve candidates, set sprint state
667
712
  2. `.valent-pipeline/steps/orchestration/sprint-groom.md` — spawn Phase 1 agents, pipeline stories through REQS → UXA → QA-A → READINESS (assembly-line parallelism), rework loop, index to SQLite
668
- 3. `.valent-pipeline/steps/orchestration/sprint-size.md` — spawn BEND/FEND with estimation step files, assign Fibonacci points, kill estimation agents
713
+ 3. `.valent-pipeline/steps/orchestration/sprint-size.md` — spawn BEND/FEND with estimate step first, assign Fibonacci points, agents persist into execution
669
714
  4. `.valent-pipeline/steps/orchestration/sprint-plan.md` — greedy packing by priority, write sprint plan + status YAML, validate, kill Phase 1 agents
670
715
  5. `.valent-pipeline/steps/orchestration/sprint-execute.md` — execute stories sequentially with budget enforcement, Phase 2 agents per story, update status YAML in real-time
671
716
  6. `.valent-pipeline/steps/orchestration/sprint-review.md` — diff planned vs actuals, record calibration data, trigger retrospective, check for next sprint
672
717
 
673
718
  **Key differences from story mode:**
674
719
  - Phase 1 agents (REQS, UXA, QA-A, READINESS) stay alive during grooming batch, killed before execution
675
- - Phase 2 agents (BEND, FEND, CRITIC, QA-B, JUDGE) killed and respawned per story during execution
720
+ - Phase 2 agents: BEND/FEND persist from sizing into story 1, then killed and respawned fresh for story 2+. CRITIC, QA-B, JUDGE spawned fresh per story.
676
721
  - Grooming indexes to `artifacts_working` table; execution queries `artifacts` (main table)
677
722
  - Budget enforcement: check cumulative execution time before each story start
678
723
  - Retrospective fires at sprint boundary, not story count
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Condition:** Only execute in sprint mode (`{is_sprint_mode}` is true).
4
4
 
5
- Execute sprint stories sequentially. Phase 2 agents (BEND, FEND, CRITIC, QA-B, JUDGE) are spawned fresh per story and killed after each.
5
+ Execute sprint stories sequentially. BEND/FEND persist from the sizing phase into story 1. CRITIC, QA-B, and JUDGE are spawned fresh for story 1. For story 2+, all Phase 2 agents are spawned fresh and killed after each.
6
6
 
7
7
  ## For Each Sprint Story (Sequential)
8
8
 
@@ -22,7 +22,8 @@ For each story in sprint order:
22
22
  1. Update story status to `development` in both `{backlog_path}` and `sprint-{n}-status.yaml`
23
23
  2. Execute the standard story flow:
24
24
  - Create story branch
25
- - Spawn Phase 2 agents per the task graph (BEND, FEND, CRITIC, QA-B, JUDGE)
25
+ - **Story 1:** BEND/FEND already alive from sizing spawn only CRITIC, QA-B, JUDGE fresh. Send implementation context to existing BEND/FEND.
26
+ - **Story 2+:** Spawn all Phase 2 agents fresh per the task graph (BEND, FEND, CRITIC, QA-B, JUDGE)
26
27
  - Agents query Knowledge/SQLite for grooming context (NOT in-context from Phase 1)
27
28
  - Monitor execution, handle rejections, gate verdicts
28
29
  - On JUDGE SHIP: merge branch, record actuals
@@ -2,33 +2,36 @@
2
2
 
3
3
  **Condition:** Only execute in sprint mode (`{is_sprint_mode}` is true).
4
4
 
5
- ## Step 1: Spawn Estimation Agents
5
+ ## Step 1: Spawn BEND/FEND
6
6
 
7
- Spawn BEND with `.valent-pipeline/steps/bend/estimate.md` step file only (no implementation tools).
7
+ Scan groomed stories' `testing_profiles` in `{backlog_path}`:
8
8
 
9
- If any groomed stories have `fullstack-web` or `frontend-only` surface, also spawn FEND with `.valent-pipeline/steps/fend/estimate.md`.
9
+ - Spawn BEND if any groomed story has `api` or `data-pipeline` in `testing_profiles`
10
+ - Spawn FEND if any groomed story has `ui` in `testing_profiles`
10
11
 
11
- Pass `{estimation_model}` and `{correction_directives}` (calibration directives) in the spawn context.
12
+ Spawn with their normal prompt template and pass `.valent-pipeline/steps/{agent}/estimate.md` as the first step. Pass `{estimation_model}` and `{correction_directives}` (calibration directives) in the spawn context.
13
+
14
+ These agents persist into execution — they are NOT killed after sizing.
12
15
 
13
16
  ## Step 2: Size Each Groomed Story
14
17
 
15
18
  For each story with status `groomed`:
16
19
 
17
20
  1. Update status to `sizing` in `{backlog_path}`
18
- 2. Send story context (reqs-brief, uxa-spec, qa-test-spec) to BEND
19
- 3. BEND writes `bend-estimation.md` with Fibonacci points
20
- 4. If full-stack: FEND writes `fend-estimation.md` with Fibonacci points
21
+ 2. Read story's `testing_profiles` from `{backlog_path}`
22
+ 3. Dispatch based on profiles:
23
+ - `[api]` or `[data-pipeline]`: send story context to BEND only
24
+ - `[ui]` only: send story context to FEND only
25
+ - `[api, ui]` (fullstack): send story context to both BEND and FEND
26
+ 4. Agents write estimation files (`bend-estimation.md` and/or `fend-estimation.md`)
21
27
  5. **Record points:**
22
- - Backend-only: `story_points = BEND estimate`
23
- - Full-stack: `story_points = BEND estimate + FEND estimate`
28
+ - Backend-only (`[api]`): `story_points = BEND estimate`
29
+ - Frontend-only (`[ui]`): `story_points = FEND estimate`
30
+ - Fullstack (`[api, ui]`): `story_points = BEND estimate + FEND estimate`
24
31
  - Data-pipeline: `story_points = BEND estimate`
25
32
  6. Update story's `story_points` field in `{backlog_path}`
26
33
 
27
- ## Step 3: Kill Estimation Agents
28
-
29
- In epic/project mode: kill BEND and FEND after sizing all stories. They will be respawned fresh per story during execution (each story needs clean code context).
30
-
31
- ## Step 4: Update Sprint State
34
+ ## Step 3: Update Sprint State
32
35
 
33
36
  Update `pipeline-state.json`: `current_sprint.phase = "planning"`.
34
37
 
@@ -97,7 +97,7 @@ Phase 1 agents (REQS, UXA, QA-A, READINESS) stay alive across the grooming batch
97
97
 
98
98
  Read and follow `.valent-pipeline/steps/orchestration/sprint-size.md`.
99
99
 
100
- BEND/FEND estimate Fibonacci points per story. Kill estimation agents after sizing.
100
+ BEND/FEND estimate Fibonacci points per story (filtered by `testing_profiles`). Agents persist into story 1 execution.
101
101
 
102
102
  #### 4f. Sprint Planning
103
103
 
@@ -111,7 +111,7 @@ Phase 1 agents (REQS, UXA, QA-A, READINESS) stay alive across the grooming batch
111
111
 
112
112
  Read and follow `.valent-pipeline/steps/orchestration/sprint-size.md`.
113
113
 
114
- BEND/FEND estimate Fibonacci points per story. Kill estimation agents after sizing.
114
+ BEND/FEND estimate Fibonacci points per story (filtered by `testing_profiles`). Agents persist into story 1 execution.
115
115
 
116
116
  #### 4f. Sprint Planning
117
117