@quolu/lattice 0.97.0 → 0.98.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.97.0",
3
+ "version": "0.98.0",
4
4
  "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
5
  "author": {
6
6
  "name": "Quo / クオ at kitepon.dev",
package/src/cli-help.mjs CHANGED
@@ -88,7 +88,6 @@ Read commands:
88
88
  show --plan <key> --task <id> --json # 個別ToDoと最新bounded note contextを追加操作なしで返す
89
89
  note list --plan <key> [--task <id>] --json # note全履歴の診断面(通常read/startでは不要)
90
90
  notice list [--lane <lane>] [--include-acked] [--json] # 着手できるようになった工程の知らせ(既定は未ackだけ。lane省略で全lane)
91
- nudge [--json] # 前の工程が終わっているのに未着手の工程を担当ごとに返し、発火(着手)と、動けない時の止め(todo block)を促す(読むだけ)
92
91
  blockers [--json] # 止めのある工程を全部返す(題・担当・理由の全文・止めた時刻と者・外すコマンド。読むだけ。外すのは誰でも todo unblock)
93
92
  bindings [--plan <key>] [--json] # compile_binding付きTaskをTODO identityつきで投影する
94
93
  display read [--json] # host表示用の工程表読取(lattice.todo_display_read_result.v1)。不整合でも断らずstateで返す
@@ -308,7 +307,6 @@ const SUBCOMMAND_USAGE = Object.freeze({
308
307
  'todo notice': 'todo notice list [--lane <lane>] [--include-acked] [--json] | ack --lane <lane> --notice <id>[,<id>...] [--json]',
309
308
  'todo notice list': 'todo notice list [--lane <lane>] [--include-acked] [--json] # lattice.todo_notice_list_result.v1',
310
309
  'todo notice ack': 'todo notice ack --lane <lane> --notice <id>[,<id>...] [--json] # lattice.todo_notice_ack_result.v1 {acked, already, closed}',
311
- 'todo nudge': 'todo nudge [--json] # lattice.todo_nudge_result.v1 {lanes: [{lane, tasks: [{fire_actions, stop_action, prompt}]}]}',
312
310
  'todo blockers': 'todo blockers [--json] # lattice.todo_blockers_result.v1 {blockers: [{plan_key, task_id, title, lane, reason, blocked_at, blocked_by, unblock_action}]}',
313
311
  'todo wait': 'todo wait --plan <key> --task <id> [--reason <text>] | --cancel [--json] # lattice.todo_wait_result.v1 {state: waiting|startable_now|not_pending|cancelled}',
314
312
  'todo bindings': 'todo bindings [--plan <key>] [--json]',
@@ -1,8 +1,13 @@
1
1
  // Blockers (blockers-list, docs/architecture/dfd-blockers.md): every blocked task in the chart with its full reason,
2
2
  // who stopped it and when, and the command to lift it. Read-only; `todo unblock` stays open to any seat.
3
3
 
4
- /** Blocked tasks of every member, sorted by plan_key then task_id. */
5
- export function projectTodoBlockers(store) {
4
+ export const todoBlockerKey = (planKey, taskId) => `${planKey}\u0000${taskId}`;
5
+
6
+ /**
7
+ * Blocked tasks of every member, sorted by plan_key then task_id. `blockEvents` (todoBlockerKey -> event) supplies
8
+ * the block event of a task carried blocked across a revision (blockers-carry).
9
+ */
10
+ export function projectTodoBlockers(store, { blockEvents = new Map() } = {}) {
6
11
  const blockers = [];
7
12
  for (const member of store.members) {
8
13
  const planKey = member.plan.plan_key;
@@ -11,7 +16,7 @@ export function projectTodoBlockers(store) {
11
16
  for (const state of member.tasks) {
12
17
  if (state.status !== 'blocked') continue;
13
18
  const task = member.plan.tasks.find(({ task_id: id }) => id === state.task_id);
14
- const event = lastBlock.get(state.task_id);
19
+ const event = lastBlock.get(state.task_id) ?? blockEvents.get(todoBlockerKey(planKey, state.task_id));
15
20
  blockers.push({
16
21
  plan_key: planKey,
17
22
  task_id: state.task_id,
package/src/todo-cli.mjs CHANGED
@@ -84,6 +84,7 @@ import {
84
84
  readTodoStructureSource,
85
85
  todoStructureSourceRef,
86
86
  resolveTodoStartRetractionBinding,
87
+ readTodoCarriedBlocks,
87
88
  readTodoWitnessSet,
88
89
  todoWitnessRef,
89
90
  writeTodoWitnessSet,
@@ -170,8 +171,7 @@ import {
170
171
  import { compileSeamProposalArtifact, declaredConcernSymbols } from './seam-proposal.mjs';
171
172
  import { collectSensorEvidence } from './sensor-adapter.mjs';
172
173
  import { newTodoNotices, projectTodoNotices, waitInEffect } from './todo-notices.mjs';
173
- import { projectTodoBlockers } from './todo-blockers.mjs';
174
- import { projectTodoNudges } from './todo-nudges.mjs';
174
+ import { projectTodoBlockers, todoBlockerKey } from './todo-blockers.mjs';
175
175
  import {
176
176
  ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
177
177
  } from './todo-notice-store.mjs';
@@ -309,7 +309,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
309
309
  'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
310
310
  'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
311
311
  'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
312
- 'retract', 'dependency', 'add', 'notice', 'wait', 'nudge', 'blockers',
312
+ 'retract', 'dependency', 'add', 'notice', 'wait', 'blockers',
313
313
  ]);
314
314
 
315
315
  function typedArgumentFailure(stderr, code, message, detail, context = {}) {
@@ -371,7 +371,6 @@ const TODO_FLAG_SPECS = Object.freeze({
371
371
  show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
372
372
  'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
373
373
  'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
374
- nudge: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
375
374
  blockers: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
376
375
  wait: Object.freeze({ known: ['plan', 'task', 'reason', 'cancel', 'json'], required: ['plan', 'task'], booleans: ['cancel', 'json'] }),
377
376
  'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
@@ -4665,21 +4664,6 @@ async function declaredWitnessRows(repoRoot, store) {
4665
4664
  return (planKey, taskId) => rows.get(planKey)?.has(taskId) === true;
4666
4665
  }
4667
4666
 
4668
- /**
4669
- * `todo nudge` (sweep-list, dfd-nudge.md): the ready set by lane with fire/stop prompts. Read-only. A directory with
4670
- * no Store yet answers an empty list, since the BellTeam run walks every chart directory.
4671
- */
4672
- async function nudgeList({ repoRoot }) {
4673
- const store = await readTodoStoreOrNull(repoRoot);
4674
- const result = {
4675
- schema: 'lattice.todo_nudge_result.v1', project_id: store?.project_id ?? null,
4676
- lanes: store === null ? [] : projectTodoNudges(store, { declared: await declaredWitnessRows(repoRoot, store) }),
4677
- result_digest: '',
4678
- };
4679
- result.result_digest = todoSelfDigest(result, 'result_digest');
4680
- return result;
4681
- }
4682
-
4683
4667
  /** The Store, or null where none exists yet (the BellTeam reads walk every chart directory). */
4684
4668
  async function readTodoStoreOrNull(repoRoot) {
4685
4669
  try { return await readTodoStore({ repoRoot }); }
@@ -4692,9 +4676,19 @@ async function readTodoStoreOrNull(repoRoot) {
4692
4676
  /** `todo blockers` (blockers-list, dfd-blockers.md): every blocked task with its full reason and unblock command. */
4693
4677
  async function blockerList({ repoRoot }) {
4694
4678
  const store = await readTodoStoreOrNull(repoRoot);
4679
+ // blockers-carry: a task blocked before a revision has its block event in an earlier version's journal.
4680
+ const blockEvents = new Map();
4681
+ for (const member of store?.members ?? []) {
4682
+ const taskIds = member.tasks.filter((state) => state.status === 'blocked' && !member.journal.events
4683
+ .some((event) => event.kind === 'block' && event.task_id === state.task_id)).map(({ task_id: id }) => id);
4684
+ if (taskIds.length === 0) continue;
4685
+ for (const [taskId, event] of await readTodoCarriedBlocks({ repoRoot, member, taskIds })) {
4686
+ if (event !== null) blockEvents.set(todoBlockerKey(member.plan.plan_key, taskId), event);
4687
+ }
4688
+ }
4695
4689
  const result = {
4696
4690
  schema: 'lattice.todo_blockers_result.v1', project_id: store?.project_id ?? null,
4697
- blockers: store === null ? [] : projectTodoBlockers(store),
4691
+ blockers: store === null ? [] : projectTodoBlockers(store, { blockEvents }),
4698
4692
  result_digest: '',
4699
4693
  };
4700
4694
  result.result_digest = todoSelfDigest(result, 'result_digest');
@@ -5262,8 +5256,6 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
5262
5256
  if (isNoticeLane(flags.lane) && ids.length > 0 && ids.every((id) => /^[0-9a-f]{64}$/u.test(id))) {
5263
5257
  action = (repoRoot) => noticeAck({ repoRoot, env, lane: flags.lane, ids });
5264
5258
  }
5265
- } else if (argv[0] === 'nudge' && matchFlagCommand(argv, ['nudge'], TODO_FLAG_SPECS.nudge) !== null) {
5266
- action = (repoRoot) => nudgeList({ repoRoot });
5267
5259
  } else if (argv[0] === 'blockers' && matchFlagCommand(argv, ['blockers'], TODO_FLAG_SPECS.blockers) !== null) {
5268
5260
  action = (repoRoot) => blockerList({ repoRoot });
5269
5261
  } else if (argv[0] === 'wait' && matchFlagCommand(argv, ['wait'], TODO_FLAG_SPECS.wait) !== null) {
@@ -1715,6 +1715,37 @@ async function inheritedTodoCoordination(repoRoot, plan) {
1715
1715
  return null;
1716
1716
  }
1717
1717
 
1718
+ /**
1719
+ * blockers-carry (Ludmila agreed): for each of `taskIds` (blocked, no block event in this version), the block event in
1720
+ * effect when it was carried blocked, from the retained predecessor journals along predecessor_plan_digest (walked
1721
+ * once per member). Follows a carry only when it carried the task blocked. Read only; a missing version, an uncarried
1722
+ * or non-blocked carry, or any read error leaves the task null.
1723
+ */
1724
+ export async function readTodoCarriedBlocks({ repoRoot = process.cwd(), member, taskIds }) {
1725
+ const found = new Map(taskIds.map((id) => [id, null]));
1726
+ const carriedBlocked = (genesis, id) => (genesis?.state_migration ?? []).find((migration) => migration.to_task_id === id
1727
+ && CARRY_STATE_POLICIES.includes(migration.state_policy) && migration.state?.status === 'blocked')?.from_task_id ?? null;
1728
+ if (!member.plan.predecessor_plan_digest || taskIds.length === 0) return found;
1729
+ try {
1730
+ const byDigest = await retainedPlanVersions(repoRoot, member.plan);
1731
+ let open = new Map(taskIds.map((id) => [id, carriedBlocked(member.journal.events[0], id)]).filter(([, from]) => from));
1732
+ for (let digest = member.plan.predecessor_plan_digest, steps = 0; open.size > 0 && digest && steps < byDigest.size; steps += 1) {
1733
+ const predecessor = byDigest.get(digest);
1734
+ if (predecessor === undefined) break;
1735
+ const { events } = await readJournal(repoRoot, predecessor.journalRef);
1736
+ const next = new Map();
1737
+ for (const [taskId, id] of open) {
1738
+ const block = events.findLast((event) => event.kind === 'block' && event.task_id === id);
1739
+ if (block !== undefined) found.set(taskId, block);
1740
+ else if (carriedBlocked(events[0], id)) next.set(taskId, carriedBlocked(events[0], id));
1741
+ }
1742
+ open = next;
1743
+ digest = predecessor.plan.predecessor_plan_digest;
1744
+ }
1745
+ } catch { /* an unreadable predecessor leaves the remaining tasks null */ }
1746
+ return found;
1747
+ }
1748
+
1718
1749
  /**
1719
1750
  * Composes the source plan's recorded task migrations back to the version whose topology the
1720
1751
  * connection names (u03): returns the source task id it maps to now, 'removed', or null (unknown).
@@ -1,37 +0,0 @@
1
- // Nudges (sweep-list, docs/architecture/dfd-nudge.md): the ready set grouped by lane, each task with the prompt to
2
- // fire it and, if it cannot move once fired, to set a stop. Read-only; no other condition (the Owner's spec).
3
-
4
- import { startPath } from './todo-notices.mjs';
5
- import { projectTodoStatus, TODO_STATUS_DISPATCH_ONLY } from './todo-status.mjs';
6
-
7
- const laneOrder = (lane) => (lane === null ? '\u{10FFFF}' : lane);
8
-
9
- /** `declared(planKey, taskId)` says whether an enforced plan's witness set records the task's row. */
10
- export function projectTodoNudges(store, { declared = () => true } = {}) {
11
- const members = new Map(store.members.map((member) => [member.plan.plan_key, member]));
12
- const lanes = new Map();
13
- for (const ready of projectTodoStatus(store, TODO_STATUS_DISPATCH_ONLY).next_ready) {
14
- const member = members.get(ready.plan_key);
15
- const task = member?.plan.tasks.find(({ task_id: id }) => id === ready.task_id);
16
- if (task === undefined) continue;
17
- const planKey = member.plan.plan_key;
18
- const fire = startPath(planKey, task.task_id, member.coordination?.mode ?? null, declared(planKey, task.task_id));
19
- const stop = `lattice todo block --plan ${planKey} --task ${task.task_id} --reason <why it cannot move>`;
20
- const lane = task.lane ?? null;
21
- if (!lanes.has(lane)) lanes.set(lane, []);
22
- lanes.get(lane).push({
23
- plan_key: planKey,
24
- plan_version: member.plan.plan_version,
25
- task_id: task.task_id,
26
- title: task.title,
27
- done_condition: task.done_condition ?? null,
28
- fire_actions: fire,
29
- stop_action: stop,
30
- prompt: `${planKey}/${task.task_id} 「${task.title}」: its predecessors are finished and it is not started.`
31
- + ` Fire it: ${fire.map((command) => `\`${command}\``).join(' then ')}.`
32
- + ` If it cannot move once fired, set a stop: \`${stop}\`.`,
33
- });
34
- }
35
- return [...lanes].sort(([left], [right]) => (laneOrder(left) < laneOrder(right) ? -1 : 1))
36
- .map(([lane, tasks]) => ({ lane, tasks }));
37
- }