@nanobpm/nano-workforce 0.121.0 → 0.122.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.
@@ -142,8 +142,9 @@ test("record-wave retries the same wave when a task is still pending", async ()
142
142
  trialMergeSkipReason: "wave-still-pending",
143
143
  });
144
144
  assertEquals((planUpdates[0].patch as Record<string, unknown>).gate_wave, 1);
145
- // Retry keeps the projection on the same (still-pending) wave.
146
- assertEquals((planUpdates[0].patch as Record<string, unknown>).current_wave, 1);
145
+ // Wave progress (current_wave/wave_label) was retired as a stored projection (epic #412) — derived
146
+ // from `plan_tasks` by the plan_wave_label VIEW — so record-wave no longer writes it.
147
+ assertEquals("current_wave" in (planUpdates[0].patch as Record<string, unknown>), false);
147
148
  // Domain-phase projection (#261): more waves remain, so the epic stays Implementing (wave n/t).
148
149
  assertEquals((planUpdates[0].patch as Record<string, unknown>).epic_phase, "Implementing (wave 2/2)");
149
150
  });
@@ -171,20 +172,21 @@ test("record-wave pins current_wave to the last index and clears gate_wave on th
171
172
  app,
172
173
  );
173
174
 
174
- // Final wave (2 of 3): no successor wave — gate cleared, projection pinned to N-1 so the
175
- // epics-index reads 3/3 rather than the one-past-the-end nextWave (3).
175
+ // Final wave (2 of 3): no successor wave — gate cleared. Wave progress (current_wave/wave_label)
176
+ // is no longer a stored column (epic #412; derived from `plan_tasks` by the plan_wave_label VIEW),
177
+ // so record-wave writes neither.
176
178
  assertEquals((planUpdates[0].patch as Record<string, unknown>).gate_wave, null);
177
- assertEquals((planUpdates[0].patch as Record<string, unknown>).current_wave, 2);
178
- assertEquals((planUpdates[0].patch as Record<string, unknown>).wave_label, "3/3");
179
+ assertEquals("current_wave" in (planUpdates[0].patch as Record<string, unknown>), false);
180
+ assertEquals("wave_label" in (planUpdates[0].patch as Record<string, unknown>), false);
179
181
  // Domain-phase projection (#261): the final wave landed with no successor and no trial merge, so
180
182
  // the epic enters Finalizing (record-results then advances to the Dispatched terminal).
181
183
  assertEquals((planUpdates[0].patch as Record<string, unknown>).epic_phase, "Finalizing");
182
184
  });
183
185
 
184
- test("record-wave keeps all wave-progress fields NULL for a taskless plan (waveCount 0)", async () => {
186
+ test("record-wave writes no wave-progress columns for a taskless plan (waveCount 0)", async () => {
185
187
  // A taskless plan runs record-wave with waveCount 0 (the MI `implement` step completed
186
- // immediately). All three progress fields must stay NULL together never current_wave=0 against
187
- // a NULL wave_label, which would clobber record-plan/select-wave's NULL projection.
188
+ // immediately). Wave progress was retired as a stored projection (epic #412), so record-wave never
189
+ // writes current_wave/wave_label regardless.
188
190
  const { app, planUpdates } = fakeApp([]);
189
191
 
190
192
  await handler(
@@ -201,8 +203,8 @@ test("record-wave keeps all wave-progress fields NULL for a taskless plan (waveC
201
203
  );
202
204
 
203
205
  const patch = planUpdates[0].patch as Record<string, unknown>;
204
- assertEquals(patch.current_wave, null);
205
- assertEquals(patch.wave_label, null);
206
+ assertEquals("current_wave" in patch, false);
207
+ assertEquals("wave_label" in patch, false);
206
208
  });
207
209
 
208
210
  test("record-wave skips trial merge for mergify-queue repos with 2+ heads", async () => {
@@ -302,17 +302,15 @@ const handler: AppJobHandler<In, Out> = async (job, app) => {
302
302
  const nextWave = stillPendingCurrentWave ? currentWave : currentWave + 1;
303
303
  const hasMoreWaves = stillPendingCurrentWave || nextWave < waveCount;
304
304
 
305
- // Operator-visibility projection (issue #137): keep plans.current_wave tracking the wave the
306
- // fleet is on. While more waves remain, point it at the wave about to run (select-wave re-writes
307
- // the same value when it dispatches); on the final wave, pin it to the last index so a finished
308
- // epic reads N/N (nextWave would be waveCount, one past the last band). Display-only.
305
+ // Wave index the epic is now on (issue #137): while more waves remain, the wave about to run; on
306
+ // the final wave, pinned to the last index so a finished epic reads N/N (nextWave would be
307
+ // waveCount, one past the last band). This is a LOCAL value only — it is used below to derive the
308
+ // `epic_phase` (Implementing wave n/t) and the domain phase.
309
309
  const projectedCurrentWave = hasMoreWaves ? nextWave : Math.max(0, waveCount - 1);
310
- // Keep the three progress fields consistent: a taskless plan (waveCount 0 the MI `implement`
311
- // step completed immediately with no waves) has no wave to be on, so current_wave and wave_label
312
- // both stay NULL rather than writing current_wave=0 against a NULL label (and clobbering the NULL
313
- // projection record-plan/select-wave already recorded).
314
- const currentWaveProjection = waveCount > 0 ? projectedCurrentWave : null;
315
- const waveLabel = waveCount > 0 ? `${projectedCurrentWave + 1}/${waveCount}` : null;
310
+ // Operator-visibility wave progress (current_wave / wave_label) was RETIRED as a stored projection
311
+ // (epic #412) it is now derived from `plan_tasks` by the `plan_wave_label` / `plan_read_model`
312
+ // VIEWs (060/061), so this worker no longer denormalises it (select-wave no longer writes it
313
+ // either). `projectedCurrentWave` above is not persisted; it only feeds the phase derivation.
316
314
 
317
315
  // Domain-phase projection (#261): the wave landed — stamp the phase the epic is ENTERING next,
318
316
  // which is data-dependent here (unlike the structural spine writers). A trial merge runs → Trial
@@ -336,8 +334,6 @@ const handler: AppJobHandler<In, Out> = async (job, app) => {
336
334
  try {
337
335
  await plans(app.data).update(planKey, {
338
336
  gate_wave: hasMoreWaves ? currentWave : null,
339
- current_wave: currentWaveProjection,
340
- wave_label: waveLabel,
341
337
  epic_phase: epicPhase,
342
338
  updated_at: ts,
343
339
  });
@@ -67,21 +67,22 @@ async function selectWave(rows: Row[], deps: DepRow[]) {
67
67
  return out as { waveTasks: unknown[] };
68
68
  }
69
69
 
70
- test("select-wave projects the active wave onto plans.current_wave", async () => {
70
+ test("select-wave dispatches the active wave without writing wave-progress columns", async () => {
71
71
  const rows: Row[] = [
72
72
  { id: 1, plan_key: "owner/repo#63", task_id: "a", title: "A", prompt: "do A", status: "pending", wave: 1 },
73
73
  ];
74
- const plans: Record<string, unknown>[] = [{ plan_key: "owner/repo#63", current_wave: 0 }];
74
+ const plans: Record<string, unknown>[] = [{ plan_key: "owner/repo#63" }];
75
75
  const out = await handler(
76
76
  { variables: { planKey: "owner/repo#63", currentWave: 1 }, elementId: "select-wave" } as any,
77
77
  fakeApp(rows, [], plans),
78
78
  );
79
79
  assertEquals((out as { waveTasks: unknown[] }).waveTasks.length, 1);
80
- assertEquals(plans[0].current_wave, 1);
81
- // wave_count is derived from the levelized rows (max wave + 1) and the 1-based "X/N" label
82
- // is pre-formatted for the epics-index at-a-glance column.
83
- assertEquals(plans[0].wave_count, 2);
84
- assertEquals(plans[0].wave_label, "2/2");
80
+ // Wave progress (current_wave/wave_count/wave_label) was retired as a stored projection (epic
81
+ // #412; the columns are dropped by migration 070) it is derived from `plan_tasks` by the
82
+ // plan_wave_label VIEW so select-wave introduces no wave-progress field onto the plan row.
83
+ assertEquals(plans[0].current_wave, undefined);
84
+ assertEquals(plans[0].wave_count, undefined);
85
+ assertEquals(plans[0].wave_label, undefined);
85
86
  // Domain-phase projection (#261): dispatching the wave marks the epic Implementing (wave n/t),
86
87
  // derived from this worker's BPMN element id + the levelize records.
87
88
  assertEquals(plans[0].epic_phase, "Implementing (wave 2/2)");
@@ -124,17 +125,18 @@ test("select-wave leaves bound_artifacts untouched for a root epic (no resolvedA
124
125
  assertEquals(plans[0].bound_artifacts, undefined);
125
126
  });
126
127
 
127
- test("select-wave nulls all three progress fields when there are no levelized rows", async () => {
128
- // No plan_tasks rows => waveCount 0. current_wave must be NULL too (not a stray index against a
129
- // NULL wave_count/wave_label), matching the documented "NULL until dispatched with tasks".
130
- const plans: Record<string, unknown>[] = [{ plan_key: "owner/repo#63", current_wave: 5 }];
128
+ test("select-wave writes no wave-progress columns when there are no levelized rows", async () => {
129
+ // Wave progress was retired as a stored projection (epic #412; the columns are dropped by
130
+ // migration 070; it is derived from `plan_tasks` by the plan_wave_label VIEW), so select-wave
131
+ // introduces no wave-progress field onto the plan row.
132
+ const plans: Record<string, unknown>[] = [{ plan_key: "owner/repo#63" }];
131
133
  await handler(
132
134
  { variables: { planKey: "owner/repo#63", currentWave: 0 } } as any,
133
135
  fakeApp([], [], plans),
134
136
  );
135
- assertEquals(plans[0].current_wave, null);
136
- assertEquals(plans[0].wave_count, null);
137
- assertEquals(plans[0].wave_label, null);
137
+ assertEquals(plans[0].current_wave, undefined);
138
+ assertEquals(plans[0].wave_count, undefined);
139
+ assertEquals(plans[0].wave_label, undefined);
138
140
  });
139
141
 
140
142
  test("select-wave leaves dependents pending behind a waiting-for-lane dependency", async () => {
@@ -78,17 +78,16 @@ const handler: AppJobHandler<In, Out> = async (job, app) => {
78
78
  : [];
79
79
  try {
80
80
  await plans(app.data).update(planKey, {
81
- // Keep the three progress fields consistent: with no levelized rows (waveCount 0) there is
82
- // no wave to implement, so current_wave is NULL too never a stray index against NULL N.
83
- current_wave: waveCount > 0 ? currentWave : null,
84
- wave_count: waveCount > 0 ? waveCount : null,
85
- wave_label: waveCount > 0 ? `${currentWave + 1}/${waveCount}` : null,
81
+ // Operator-visibility wave progress (current_wave / wave_count / wave_label) was RETIRED as a
82
+ // stored projection (epic #412) it is now derived from `plan_tasks` by the `plan_wave_label`
83
+ // / `plan_read_model` VIEWs (060/061), so select-wave no longer denormalises it. This write
84
+ // still stamps the derived domain phase and the inter-epic gate's bound artifacts.
86
85
  ...(epicPhase ? { epic_phase: epicPhase } : {}),
87
86
  ...(boundArtifacts.length > 0 ? { bound_artifacts: JSON.stringify(boundArtifacts) } : {}),
88
87
  updated_at: ts,
89
88
  });
90
89
  } catch (err) {
91
- app.log.error(`select-wave: projecting current_wave failed for ${planKey}`, {
90
+ app.log.error(`select-wave: projecting plan row (epic phase / bound artifacts) failed for ${planKey}`, {
92
91
  err: String(err),
93
92
  });
94
93
  }