@quolu/lattice 0.85.0 → 0.85.2

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.
@@ -118,9 +118,13 @@ export function createTodoReadiness(store) {
118
118
  return node?.schema !== 'lattice.todo_plan.v4' || node.phase_status === 'active';
119
119
  }
120
120
 
121
- function startedSuccessor(key) {
122
- return [...(outgoing.get(key) ?? [])].some((successor) => nodes.get(successor)?.status !== 'pending');
121
+ /** a28: the successors that already left pending, sorted, so a refusal can name them. */
122
+ function startedSuccessors(key) {
123
+ return [...(outgoing.get(key) ?? [])].map((successor) => nodes.get(successor))
124
+ .filter((node) => node !== undefined && node.status !== 'pending')
125
+ .map(({ plan_key, task_id, status }) => ({ plan_key, task_id, status })).sort(byRef);
123
126
  }
127
+ const startedSuccessor = (key) => startedSuccessors(key).length > 0;
124
128
 
125
129
  return {
126
130
  key: taskKey,
@@ -131,6 +135,7 @@ export function createTodoReadiness(store) {
131
135
  isReady: (key) => nodes.get(key)?.status === 'pending'
132
136
  && ownPhaseReady(key) && prerequisites(key).dependenciesDone,
133
137
  startedSuccessor,
138
+ startedSuccessors,
134
139
  phaseHasStartedSuccessor: (member, phaseId) => member.plan.schema === 'lattice.todo_plan.v4'
135
140
  ? member.plan.tasks.filter(({ phase_id }) => phase_id === phaseId)
136
141
  .some((task) => startedSuccessor(taskKey({ ...member.plan, ...task })))
@@ -173,8 +178,13 @@ export function validateProspectiveEvent({ store, member, event }) {
173
178
  return refused('invalid_done_transition', prerequisites.cause, prerequisites.blocking);
174
179
  }
175
180
  if (event.kind === 'reopen' && event.payload.override_reason === null && readiness.startedSuccessor(key)) {
181
+ const started = readiness.startedSuccessors(key);
182
+ const on = `--plan ${member.plan.plan_key} --task ${event.task_id}`;
176
183
  return refused('reopen_has_started_successor', 'task_state', {
177
- next_action: `lattice todo split --plan ${member.plan.plan_key} --input <file>`,
184
+ started_successors: started,
185
+ next_action: `${started.map((task) => `${task.plan_key}/${task.task_id} (${task.status})`).join(', ')}`
186
+ + ` already left pending after ${member.plan.plan_key}/${event.task_id}; to reopen it anyway run`
187
+ + ` \`lattice todo reopen ${on} --reason <text> --override-reason <text>\`.`,
178
188
  });
179
189
  }
180
190
  if (event.kind === 'phase_reopen' && event.payload.override_reason === null