@quolu/lattice 0.97.0 → 0.97.1

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.97.1",
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",
@@ -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,7 +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 { projectTodoBlockers, todoBlockerKey } from './todo-blockers.mjs';
174
175
  import { projectTodoNudges } from './todo-nudges.mjs';
175
176
  import {
176
177
  ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
@@ -4692,9 +4693,19 @@ async function readTodoStoreOrNull(repoRoot) {
4692
4693
  /** `todo blockers` (blockers-list, dfd-blockers.md): every blocked task with its full reason and unblock command. */
4693
4694
  async function blockerList({ repoRoot }) {
4694
4695
  const store = await readTodoStoreOrNull(repoRoot);
4696
+ // blockers-carry: a task blocked before a revision has its block event in an earlier version's journal.
4697
+ const blockEvents = new Map();
4698
+ for (const member of store?.members ?? []) {
4699
+ const taskIds = member.tasks.filter((state) => state.status === 'blocked' && !member.journal.events
4700
+ .some((event) => event.kind === 'block' && event.task_id === state.task_id)).map(({ task_id: id }) => id);
4701
+ if (taskIds.length === 0) continue;
4702
+ for (const [taskId, event] of await readTodoCarriedBlocks({ repoRoot, member, taskIds })) {
4703
+ if (event !== null) blockEvents.set(todoBlockerKey(member.plan.plan_key, taskId), event);
4704
+ }
4705
+ }
4695
4706
  const result = {
4696
4707
  schema: 'lattice.todo_blockers_result.v1', project_id: store?.project_id ?? null,
4697
- blockers: store === null ? [] : projectTodoBlockers(store),
4708
+ blockers: store === null ? [] : projectTodoBlockers(store, { blockEvents }),
4698
4709
  result_digest: '',
4699
4710
  };
4700
4711
  result.result_digest = todoSelfDigest(result, 'result_digest');
@@ -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).