@quolu/lattice 0.97.1 → 0.99.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 +1 -1
- package/src/cli-help.mjs +7 -8
- package/src/project-cli.mjs +6 -4
- package/src/todo-cli.mjs +128 -65
- package/src/todo-external.mjs +125 -0
- package/src/todo-notices.mjs +8 -0
- package/src/todo-readiness.mjs +25 -5
- package/src/todo-status.mjs +3 -1
- package/src/todo-store.mjs +21 -4
- package/src/todo-nudges.mjs +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.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で返す
|
|
@@ -140,9 +139,10 @@ Write commands:
|
|
|
140
139
|
evidence anchor [--json] # 既存の証拠をgcから守る印(refs/lattice/evidence/<oid>)を付ける。commit済みにはならない
|
|
141
140
|
# done状態と完了時刻を維持し、最新doneへ追記eventで証拠を再束縛する
|
|
142
141
|
start --plan <key> --task <id> --rebind --reason <text> # 改訂でcarryされたin-progressへ現版のstart束縛を積み直す(ADR 0191)
|
|
143
|
-
dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
144
|
-
dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
142
|
+
dependency connect [--from-project <id>] --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
143
|
+
dependency disconnect [--from-project <id>] --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
145
144
|
# 開発中に発見した依存を明示接続する。同一plan内の辺はplan本体を軽い改訂で書き換え(plan_versionが変わる)、plan跨ぎは台帳に積む。依存の自動推定は行わない
|
|
145
|
+
# --from-project = 別の工程表(別プロジェクト)の工程を前工程にする。LATTICE_CHARTS_ROOT/<project_id>/.lattice を読むだけで書かない。読めない間は待ちのまま
|
|
146
146
|
independence mode --plan <key> --set <witness|conversation|enforced> --reason <text>
|
|
147
147
|
# enforced = witness+未宣言・古い宣言・衝突・参照なしdone・heavy段階の監査なし閉じを止める(ADR 0200)
|
|
148
148
|
# このplanの調整方式(witness検証で並列するか、会話で調整するか)を記録する
|
|
@@ -308,7 +308,6 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
308
308
|
'todo notice': 'todo notice list [--lane <lane>] [--include-acked] [--json] | ack --lane <lane> --notice <id>[,<id>...] [--json]',
|
|
309
309
|
'todo notice list': 'todo notice list [--lane <lane>] [--include-acked] [--json] # lattice.todo_notice_list_result.v1',
|
|
310
310
|
'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
311
|
'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
312
|
'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
313
|
'todo bindings': 'todo bindings [--plan <key>] [--json]',
|
|
@@ -354,11 +353,11 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
354
353
|
'todo evidence anchor': 'todo evidence anchor [--json] # lattice.todo_evidence_anchor_result.v1 {anchored, already, missing}; no Store yet: lattice.todo_evidence_anchor_uninitialized.v1',
|
|
355
354
|
'todo evidence promote': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
|
356
355
|
'todo dependency': [
|
|
357
|
-
'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
358
|
-
'todo dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
356
|
+
'todo dependency connect [--from-project <id>] --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
357
|
+
'todo dependency disconnect [--from-project <id>] --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
359
358
|
].join('\n lattice '),
|
|
360
|
-
'todo dependency connect': 'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
361
|
-
'todo dependency disconnect': 'todo dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
359
|
+
'todo dependency connect': 'todo dependency connect [--from-project <id>] --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
360
|
+
'todo dependency disconnect': 'todo dependency disconnect [--from-project <id>] --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
362
361
|
'todo split': 'todo split --plan <key> --input <file>',
|
|
363
362
|
'todo revise': 'todo revise --plan <key> --input <file> | --schema --json',
|
|
364
363
|
'todo revise-phase': 'todo revise-phase --plan <key> --input <file> | --schema --json',
|
package/src/project-cli.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withTodoExternalTasks } from './todo-external.mjs';
|
|
1
2
|
import { gitSync } from './git-process.mjs';
|
|
2
3
|
import { constants as fsConstants } from 'node:fs';
|
|
3
4
|
import { lstat, open } from 'node:fs/promises';
|
|
@@ -240,7 +241,7 @@ function invalidStatus({ cliVersion, repoRoot, reason, nextAction = null }) {
|
|
|
240
241
|
* store読みはここでしか行わない——session開始経路が同じstoreを二度払っていたのが
|
|
241
242
|
* ADR 0131で直した欠陥である。
|
|
242
243
|
*/
|
|
243
|
-
async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts = false }) {
|
|
244
|
+
async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts = false, env = process.env }) {
|
|
244
245
|
const repoRoot = resolveRepoRoot(cwd);
|
|
245
246
|
if (repoRoot === null) {
|
|
246
247
|
return { exitCode: 1, repoRoot: null, store: null, todo: null,
|
|
@@ -290,7 +291,8 @@ async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts
|
|
|
290
291
|
return invalid('store_layout_invalid');
|
|
291
292
|
}
|
|
292
293
|
try {
|
|
293
|
-
|
|
294
|
+
// xchart: predecessors on other charts count for next_ready here too.
|
|
295
|
+
const store = await withTodoExternalTasks(await readTodoStore({ repoRoot }), env);
|
|
294
296
|
if (diagnoseStructureArtifacts) {
|
|
295
297
|
const diagnostics = await readTodoStructureArtifactDiagnostics({ repoRoot, store });
|
|
296
298
|
if (diagnostics.length > 0) {
|
|
@@ -362,7 +364,7 @@ export async function runProjectStatus({ cwd, stdout, stderr = process.stderr, c
|
|
|
362
364
|
ensureDashboardActivity = ensureTodoDashboardActivity,
|
|
363
365
|
reportDelivery = reportProjectDashboardDelivery }) {
|
|
364
366
|
const state = await resolveProjectState({
|
|
365
|
-
cwd, cliVersion, diagnoseStructureArtifacts: true,
|
|
367
|
+
cwd, cliVersion, diagnoseStructureArtifacts: true, env,
|
|
366
368
|
});
|
|
367
369
|
// dashboard活動の登録はdiscovery面の副作用として維持する(ADR 0131 Decision 4で
|
|
368
370
|
// session-context側だけが持たない、と決めた面である)。
|
|
@@ -431,7 +433,7 @@ export function projectTurn({ store, todo, actor, reason = 'store_unavailable' }
|
|
|
431
433
|
* dashboard活動の登録は行わない。現在地を知るために呼ぶ面であり、常駐面を起こす面ではない。
|
|
432
434
|
*/
|
|
433
435
|
export async function runSessionContext({ cwd, stdout, cliVersion, env = process.env }) {
|
|
434
|
-
const state = await resolveProjectState({ cwd, cliVersion });
|
|
436
|
+
const state = await resolveProjectState({ cwd, cliVersion, env });
|
|
435
437
|
const independence = state.store === null || state.todo === null
|
|
436
438
|
? [] : await summarizeIndependence({ repoRoot: state.repoRoot, store: state.store, todo: state.todo });
|
|
437
439
|
const result = {
|
package/src/todo-cli.mjs
CHANGED
|
@@ -171,8 +171,10 @@ import {
|
|
|
171
171
|
import { compileSeamProposalArtifact, declaredConcernSymbols } from './seam-proposal.mjs';
|
|
172
172
|
import { collectSensorEvidence } from './sensor-adapter.mjs';
|
|
173
173
|
import { newTodoNotices, projectTodoNotices, waitInEffect } from './todo-notices.mjs';
|
|
174
|
+
import {
|
|
175
|
+
externalCycle, readTodoExternalChart, readTodoExternalTasks, withTodoExternalTasks,
|
|
176
|
+
} from './todo-external.mjs';
|
|
174
177
|
import { projectTodoBlockers, todoBlockerKey } from './todo-blockers.mjs';
|
|
175
|
-
import { projectTodoNudges } from './todo-nudges.mjs';
|
|
176
178
|
import {
|
|
177
179
|
ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
|
|
178
180
|
} from './todo-notice-store.mjs';
|
|
@@ -310,7 +312,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
310
312
|
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
311
313
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
312
314
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
313
|
-
'retract', 'dependency', 'add', 'notice', 'wait', '
|
|
315
|
+
'retract', 'dependency', 'add', 'notice', 'wait', 'blockers',
|
|
314
316
|
]);
|
|
315
317
|
|
|
316
318
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -331,7 +333,7 @@ const REASON_FLAG_SPEC = Object.freeze({ known: ['plan', 'task', 'reason'], requ
|
|
|
331
333
|
const PHASE_REASON_FLAG_SPEC = Object.freeze({ known: ['plan', 'phase', 'reason'], required: ['plan', 'phase', 'reason'] });
|
|
332
334
|
const NOTE_FLAG_SPEC = Object.freeze({ known: ['plan', 'task', 'message', 'input', 'supersedes'], required: ['plan'] });
|
|
333
335
|
const DEPENDENCY_FLAG_SPEC = Object.freeze({
|
|
334
|
-
known: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
336
|
+
known: ['from-project', 'from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
335
337
|
required: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
336
338
|
});
|
|
337
339
|
// a18: one spec per write command is both its parser and the explanation of its refusal.
|
|
@@ -372,7 +374,6 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
372
374
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
373
375
|
'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
|
|
374
376
|
'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
|
|
375
|
-
nudge: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
376
377
|
blockers: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
377
378
|
wait: Object.freeze({ known: ['plan', 'task', 'reason', 'cancel', 'json'], required: ['plan', 'task'], booleans: ['cancel', 'json'] }),
|
|
378
379
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
@@ -408,7 +409,8 @@ function repairedCommand(head, spec, flags) {
|
|
|
408
409
|
/** `dependency connect|disconnect` flags by name (order-free), or null. */
|
|
409
410
|
function dependencyFlags(argv) {
|
|
410
411
|
const flags = matchFlagCommand(argv, argv.slice(0, 2), DEPENDENCY_FLAG_SPEC);
|
|
411
|
-
return flags !== null && IDENTIFIER_FLAGS.slice(3).every((name) => isTodoIdentifier(flags[name]))
|
|
412
|
+
return flags !== null && IDENTIFIER_FLAGS.slice(3).every((name) => isTodoIdentifier(flags[name]))
|
|
413
|
+
&& (flags['from-project'] === undefined || isTodoIdentifier(flags['from-project'])) ? flags : null;
|
|
412
414
|
}
|
|
413
415
|
|
|
414
416
|
/** a28: a read command's flags by name (order-free, --json optional) with valid identifiers, or null. */
|
|
@@ -977,9 +979,14 @@ function reopenAdvisory(plan, phases, taskId) {
|
|
|
977
979
|
async function mutate({
|
|
978
980
|
repoRoot, env, planKey, taskId, kind, payload, evidenceRef, evidenceMessage = null,
|
|
979
981
|
advisory = null, noteContext = null, structureContext = null, featureContext = null,
|
|
980
|
-
testResultRef = null, actor: carriedActor = null,
|
|
982
|
+
testResultRef = null, actor: carriedActor = null, externalTasks = null,
|
|
981
983
|
}) {
|
|
982
984
|
const actor = carriedActor ?? resolveTodoActor(env);
|
|
985
|
+
// xchart: start and authored done check predecessors on other charts too, read before the lock.
|
|
986
|
+
const external = externalTasks ?? (kind === 'start' || (kind === 'done' && payload === 'authored')
|
|
987
|
+
? (await readTodoExternalTasks(await readTodoStore({ repoRoot }), env)).external_tasks : []);
|
|
988
|
+
const validator = external.length === 0 ? validateProspectiveEvent
|
|
989
|
+
: (input) => validateProspectiveEvent({ ...input, store: { ...input.store, external_tasks: external } });
|
|
983
990
|
const evidence = evidenceRef === null && evidenceMessage === null
|
|
984
991
|
? null
|
|
985
992
|
: await resolveDoneEvidence({
|
|
@@ -1007,7 +1014,7 @@ async function mutate({
|
|
|
1007
1014
|
eventPayload = { done_mode: 'evidence_promotion', evidence };
|
|
1008
1015
|
}
|
|
1009
1016
|
const { event, snapshot, plan, phases } = await appendTodoEvent({
|
|
1010
|
-
validateProspectiveEvent,
|
|
1017
|
+
validateProspectiveEvent: validator,
|
|
1011
1018
|
repoRoot,
|
|
1012
1019
|
writer: createTodoStoreWriter({ caller: 'g5-authoring' }),
|
|
1013
1020
|
planKey,
|
|
@@ -1391,10 +1398,22 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
1391
1398
|
};
|
|
1392
1399
|
}
|
|
1393
1400
|
|
|
1401
|
+
/** xchart: the display envelope plus `external_tasks`, so a host computing readiness from it sees other charts too. */
|
|
1402
|
+
async function displayRead(repoRoot, env) {
|
|
1403
|
+
const display = await readTodoStoreForDisplay({ repoRoot });
|
|
1404
|
+
const externalTasks = display.store ? (await readTodoExternalTasks(display.store, env)).external_tasks : [];
|
|
1405
|
+
return { schema: 'lattice.todo_display_read_result.v1', ...display, external_tasks: externalTasks };
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/** xchart: the Store plus its external predecessors' states; every readiness reader reads through this. */
|
|
1409
|
+
async function readTodoStoreForReadiness({ repoRoot, env = process.env }) {
|
|
1410
|
+
return withTodoExternalTasks(await readTodoStore({ repoRoot }), env);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1394
1413
|
async function startTask({
|
|
1395
1414
|
repoRoot, env, planKey, taskId, overrideReason,
|
|
1396
1415
|
}) {
|
|
1397
|
-
const store = await
|
|
1416
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
1398
1417
|
// startはready判定にしかprojectionを使わず、resultを出力しない。
|
|
1399
1418
|
const projection = projectTodoStatus(store, TODO_STATUS_DISPATCH_ONLY);
|
|
1400
1419
|
const readyTask = projection.next_ready.find((task) => (
|
|
@@ -1463,7 +1482,7 @@ async function startTask({
|
|
|
1463
1482
|
}
|
|
1464
1483
|
return mutate({ repoRoot, env, planKey, taskId: resolvedTaskId, kind: 'start',
|
|
1465
1484
|
payload: { override_reason: overrideReason }, evidenceRef: null, advisory, noteContext,
|
|
1466
|
-
structureContext, featureContext });
|
|
1485
|
+
structureContext, featureContext, externalTasks: store.external_tasks ?? [] });
|
|
1467
1486
|
}
|
|
1468
1487
|
|
|
1469
1488
|
/** declare-without-git: HEAD does not resolve (no commit) and the plan's witness set records this task's row. */
|
|
@@ -1874,9 +1893,11 @@ const samePlanEdge = (member, fromTaskId, toTaskId) => member.plan.hard_dependen
|
|
|
1874
1893
|
* consumer planのplan-scoped chainへ。
|
|
1875
1894
|
*/
|
|
1876
1895
|
async function dependencyConnect(options) {
|
|
1877
|
-
const { repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason } = options;
|
|
1878
|
-
if (fromPlanKey !== toPlanKey) return dependencyConnectLedger(options);
|
|
1896
|
+
const { repoRoot, env, fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason } = options;
|
|
1879
1897
|
const store = await readTodoStore({ repoRoot });
|
|
1898
|
+
// xchart: --from-project omitted or this project = the in-chart routes below, unchanged.
|
|
1899
|
+
if (fromProjectId !== null && fromProjectId !== store.project_id) return dependencyConnectExternal({ ...options, store });
|
|
1900
|
+
if (fromPlanKey !== toPlanKey) return dependencyConnectLedger(options);
|
|
1880
1901
|
const member = store.members.find(({ plan }) => plan.plan_key === fromPlanKey);
|
|
1881
1902
|
const tasks = member?.plan.tasks ?? [];
|
|
1882
1903
|
// 台帳経路と同じ事前検査(plan不在・task不在・自己辺・既存辺・完了済み終点)の拒否を保つ。
|
|
@@ -1899,15 +1920,15 @@ async function dependencyConnect(options) {
|
|
|
1899
1920
|
}
|
|
1900
1921
|
|
|
1901
1922
|
/** A live ledger edge with these endpoints (cross-plan, or an earlier same-plan connect). */
|
|
1902
|
-
function liveLedgerEdge(store, { fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1923
|
+
function liveLedgerEdge(store, { fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1903
1924
|
return projectTodoCrossPlanDependencies(store.members).some((dependency) => (
|
|
1904
|
-
dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1925
|
+
dependency.from.project_id === (fromProjectId ?? store.project_id) && dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1905
1926
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId));
|
|
1906
1927
|
}
|
|
1907
1928
|
|
|
1908
1929
|
/** a28: connect of an existing edge succeeds unchanged, like a repeated done/block/retire (a12). */
|
|
1909
|
-
function dependencyUnchanged(store, { fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1910
|
-
const from = { project_id: store.project_id, plan_key: fromPlanKey, task_id: fromTaskId };
|
|
1930
|
+
function dependencyUnchanged(store, { fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1931
|
+
const from = { project_id: fromProjectId ?? store.project_id, plan_key: fromPlanKey, task_id: fromTaskId };
|
|
1911
1932
|
const to = { project_id: store.project_id, plan_key: toPlanKey, task_id: toTaskId };
|
|
1912
1933
|
const result = {
|
|
1913
1934
|
schema: 'lattice.todo_dependency_unchanged_result.v1', project_id: store.project_id,
|
|
@@ -1956,9 +1977,13 @@ async function dependencyConnectLedger({
|
|
|
1956
1977
|
project_id: store.project_id, plan_key: toPlanKey, task_id: toTaskId,
|
|
1957
1978
|
expected_topology_digest: target.plan.topology_digest,
|
|
1958
1979
|
};
|
|
1980
|
+
return appendLedgerEdge({ repoRoot, env, store, from, to, reason });
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
async function appendLedgerEdge({ repoRoot, env, store, from, to, reason }) {
|
|
1959
1984
|
const { event } = await appendTodoEvent({
|
|
1960
1985
|
validateProspectiveEvent,
|
|
1961
|
-
repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }), planKey:
|
|
1986
|
+
repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }), planKey: to.plan_key,
|
|
1962
1987
|
event: {
|
|
1963
1988
|
kind: 'cross_plan_dependency', actor: resolveTodoActor(env), payload: { from, to, reason },
|
|
1964
1989
|
},
|
|
@@ -1974,9 +1999,54 @@ async function dependencyConnectLedger({
|
|
|
1974
1999
|
return result;
|
|
1975
2000
|
}
|
|
1976
2001
|
|
|
2002
|
+
/**
|
|
2003
|
+
* xchart: wait on a task of another chart. The other chart is read read-only (plan, task, topology, cycle);
|
|
2004
|
+
* the edge is the existing ledger event on this chart's to-plan, nothing is written there.
|
|
2005
|
+
*/
|
|
2006
|
+
async function dependencyConnectExternal({
|
|
2007
|
+
repoRoot, env, store, fromProjectId, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
2008
|
+
}) {
|
|
2009
|
+
const target = store.members.find(({ plan }) => plan.plan_key === toPlanKey);
|
|
2010
|
+
if (target === undefined) {
|
|
2011
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_plan_not_found', undefined, { plan_key: toPlanKey });
|
|
2012
|
+
}
|
|
2013
|
+
if (!target.plan.tasks.some(({ task_id: taskId }) => taskId === toTaskId)) {
|
|
2014
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_task_not_found', undefined, {
|
|
2015
|
+
plan_key: toPlanKey, task_id: toTaskId,
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
const endpoints = { fromProjectId, fromPlanKey, fromTaskId, toPlanKey, toTaskId };
|
|
2019
|
+
if (liveLedgerEdge(store, endpoints)) return dependencyUnchanged(store, endpoints);
|
|
2020
|
+
const other = await readTodoExternalChart(env, fromProjectId);
|
|
2021
|
+
const source = other.members.find(({ plan }) => plan.plan_key === fromPlanKey);
|
|
2022
|
+
if (source === undefined) {
|
|
2023
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_plan_not_found', undefined, {
|
|
2024
|
+
project_id: fromProjectId, plan_key: fromPlanKey,
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
if (!source.plan.tasks.some(({ task_id: taskId }) => taskId === fromTaskId)) {
|
|
2028
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_task_not_found', undefined, {
|
|
2029
|
+
project_id: fromProjectId, plan_key: fromPlanKey, task_id: fromTaskId,
|
|
2030
|
+
});
|
|
2031
|
+
}
|
|
2032
|
+
const from = { project_id: fromProjectId, plan_key: fromPlanKey, task_id: fromTaskId,
|
|
2033
|
+
expected_topology_digest: source.plan.topology_digest };
|
|
2034
|
+
const to = { project_id: store.project_id, plan_key: toPlanKey, task_id: toTaskId,
|
|
2035
|
+
expected_topology_digest: target.plan.topology_digest };
|
|
2036
|
+
const cycle = await externalCycle({ env, fromStore: other, from, to, localStore: store });
|
|
2037
|
+
if (cycle !== null) {
|
|
2038
|
+
throw new TodoStoreError('DEPENDENCY_CYCLE', 'cross_plan_dependency_cycle', undefined, { from, to, cycle });
|
|
2039
|
+
}
|
|
2040
|
+
return appendLedgerEdge({ repoRoot, env, store, from, to, reason });
|
|
2041
|
+
}
|
|
2042
|
+
|
|
1977
2043
|
// connectの対。同一planでplan本体が持つ辺は軽量改訂で外し(a14)、それ以外は台帳の除去へ。
|
|
1978
2044
|
async function dependencyDisconnect(options) {
|
|
1979
2045
|
const { repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason } = options;
|
|
2046
|
+
// xchart: --from-project equal to this project is the in-chart route.
|
|
2047
|
+
const fromProjectId = options.fromProjectId === null || options.fromProjectId === undefined
|
|
2048
|
+
|| options.fromProjectId === (await readTodoStore({ repoRoot })).project_id ? null : options.fromProjectId;
|
|
2049
|
+
if (fromProjectId !== null) return dependencyDisconnectLedger({ ...options, fromProjectId });
|
|
1980
2050
|
if (fromPlanKey === toPlanKey) {
|
|
1981
2051
|
const store = await readTodoStore({ repoRoot });
|
|
1982
2052
|
const member = store.members.find(({ plan }) => plan.plan_key === fromPlanKey);
|
|
@@ -1991,17 +2061,17 @@ async function dependencyDisconnect(options) {
|
|
|
1991
2061
|
// 誤って張った線の除去(tombstone)。端点で一意に生きた接続を特定し、
|
|
1992
2062
|
// その接続eventが積まれているplanのplan-scoped chainへ除去eventを積む。
|
|
1993
2063
|
async function dependencyDisconnectLedger({
|
|
1994
|
-
repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
2064
|
+
repoRoot, env, fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
1995
2065
|
}) {
|
|
1996
2066
|
const store = await readTodoStore({ repoRoot });
|
|
1997
2067
|
const live = projectTodoCrossPlanDependencies(store.members).filter((dependency) => (
|
|
1998
|
-
dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
2068
|
+
dependency.from.project_id === (fromProjectId ?? store.project_id) && dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1999
2069
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId
|
|
2000
2070
|
));
|
|
2001
2071
|
if (live.length === 0) {
|
|
2002
|
-
const from = { plan_key: fromPlanKey, task_id: fromTaskId };
|
|
2072
|
+
const from = { ...(fromProjectId === null ? {} : { project_id: fromProjectId }), plan_key: fromPlanKey, task_id: fromTaskId };
|
|
2003
2073
|
const to = { plan_key: toPlanKey, task_id: toTaskId };
|
|
2004
|
-
if (fromPlanKey === toPlanKey) {
|
|
2074
|
+
if (fromPlanKey === toPlanKey && fromProjectId === null) {
|
|
2005
2075
|
const member = store.members.find(({ plan }) => plan.plan_key === toPlanKey);
|
|
2006
2076
|
const predecessors = (member?.plan.hard_dependencies ?? [])
|
|
2007
2077
|
.filter((edge) => edge.to.task_id === toTaskId).map((edge) => edge.from.task_id).sort();
|
|
@@ -2609,7 +2679,7 @@ async function splitTodo({ repoRoot, env, planKey, inputRef }) {
|
|
|
2609
2679
|
return result;
|
|
2610
2680
|
}
|
|
2611
2681
|
|
|
2612
|
-
async function status({ repoRoot }) {
|
|
2682
|
+
async function status({ repoRoot, env }) {
|
|
2613
2683
|
// No plan yet is an empty project, not a broken store: answer zero plans and how to make one.
|
|
2614
2684
|
if (await isUninitializedTodoStore({ repoRoot })) {
|
|
2615
2685
|
const result = {
|
|
@@ -2621,7 +2691,7 @@ async function status({ repoRoot }) {
|
|
|
2621
2691
|
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
2622
2692
|
return result;
|
|
2623
2693
|
}
|
|
2624
|
-
const store = await
|
|
2694
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
2625
2695
|
const result = projectTodoStatus(store, {
|
|
2626
2696
|
planNotes: await readTodoPlanNotesForStatus({ repoRoot, store }),
|
|
2627
2697
|
parallelCandidates: await readTodoParallelCandidatesForStatus({
|
|
@@ -2652,8 +2722,8 @@ async function adoptDashboardRoot({ repoRoot, env }) {
|
|
|
2652
2722
|
return result;
|
|
2653
2723
|
}
|
|
2654
2724
|
|
|
2655
|
-
async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
2656
|
-
const store = await
|
|
2725
|
+
async function todoDetail({ repoRoot, env, planKey, taskId }) {
|
|
2726
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
2657
2727
|
const [member] = selectMembers(store, planKey);
|
|
2658
2728
|
const task = selectNoteTask(member, taskId);
|
|
2659
2729
|
const state = member.tasks.find(({ task_id: current }) => current === task.task_id);
|
|
@@ -2673,6 +2743,7 @@ async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
|
2673
2743
|
task: { ...task, done_condition: task.done_condition ?? null },
|
|
2674
2744
|
design_memo: designMemoProjection(task),
|
|
2675
2745
|
state,
|
|
2746
|
+
prerequisites: taskPrerequisites(store, member, task.task_id),
|
|
2676
2747
|
note_context: context,
|
|
2677
2748
|
...(featureContext === null ? {} : { feature_context: featureContext }),
|
|
2678
2749
|
result_digest: '',
|
|
@@ -2681,6 +2752,15 @@ async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
|
2681
2752
|
return result;
|
|
2682
2753
|
}
|
|
2683
2754
|
|
|
2755
|
+
/** xchart: what a task waits on, by the readiness predicate (`ready` is the start path's own answer). */
|
|
2756
|
+
function taskPrerequisites(store, member, taskId) {
|
|
2757
|
+
const readiness = createTodoReadiness(store);
|
|
2758
|
+
const key = readiness.key({ ...member.plan, task_id: taskId });
|
|
2759
|
+
const { blocking } = readiness.prerequisites(key);
|
|
2760
|
+
return { ready: readiness.isReady(key), tasks: readiness.prerequisiteRefs(key).tasks,
|
|
2761
|
+
blocking_tasks: blocking.blocking_tasks ?? [], blocking_phases: blocking.blocking_phases ?? [] };
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2684
2764
|
/**
|
|
2685
2765
|
* `taskId === null`はplan単位note。task noteと違い宛先taskが無いので、
|
|
2686
2766
|
* 訂正できる相手はplan noteだけ、返すcontextも特定taskのものにできない。
|
|
@@ -3884,8 +3964,8 @@ function declaredStartHint(store, member, state) {
|
|
|
3884
3964
|
* a40: one task's witness row, declared by its member. Rows nobody declared stay out (an empty row
|
|
3885
3965
|
* would claim "touches nothing"); compile runs once every ready task is declared.
|
|
3886
3966
|
*/
|
|
3887
|
-
async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
3888
|
-
const store = await
|
|
3967
|
+
async function witnessDeclare({ repoRoot, env, planKey, flags }) {
|
|
3968
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
3889
3969
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
3890
3970
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
3891
3971
|
const taskId = flags.task;
|
|
@@ -3912,7 +3992,7 @@ async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
|
3912
3992
|
pointer: at, ...keys, next_action: witnessRoute(planKey) });
|
|
3913
3993
|
}
|
|
3914
3994
|
const scaffolded = await scaffoldWitnessDraft({ repoRoot, planKey, draft });
|
|
3915
|
-
const waitingFor = projectTodoStatus(await
|
|
3995
|
+
const waitingFor = projectTodoStatus(await readTodoStoreForReadiness({ repoRoot, env }), TODO_STATUS_DISPATCH_ONLY).next_ready
|
|
3916
3996
|
.filter((task) => task.plan_key === planKey && !keep.has(task.task_id))
|
|
3917
3997
|
.map(({ task_id: id }) => id).sort();
|
|
3918
3998
|
// declare-without-git: a Store root with no commit cannot be observed, so the row is recorded and not compiled.
|
|
@@ -4410,8 +4490,8 @@ export async function renderTodoGanttForProject({
|
|
|
4410
4490
|
repoRoot, stable = false, displayName = null, env = process.env, readModel = null,
|
|
4411
4491
|
scope = DEFAULT_GANTT_SCOPE, degraded = false,
|
|
4412
4492
|
}) {
|
|
4413
|
-
const store = readModel
|
|
4414
|
-
?? (stable ? await readTodoStoreStable({ repoRoot }) : await readTodoStore({ repoRoot }));
|
|
4493
|
+
const store = await withTodoExternalTasks(readModel
|
|
4494
|
+
?? (stable ? await readTodoStoreStable({ repoRoot }) : await readTodoStore({ repoRoot })), env);
|
|
4415
4495
|
const identity = displayName === null
|
|
4416
4496
|
? await resolveProjectIdentity({ repoRoot, projectId: store.project_id, env })
|
|
4417
4497
|
: { displayName };
|
|
@@ -4666,21 +4746,6 @@ async function declaredWitnessRows(repoRoot, store) {
|
|
|
4666
4746
|
return (planKey, taskId) => rows.get(planKey)?.has(taskId) === true;
|
|
4667
4747
|
}
|
|
4668
4748
|
|
|
4669
|
-
/**
|
|
4670
|
-
* `todo nudge` (sweep-list, dfd-nudge.md): the ready set by lane with fire/stop prompts. Read-only. A directory with
|
|
4671
|
-
* no Store yet answers an empty list, since the BellTeam run walks every chart directory.
|
|
4672
|
-
*/
|
|
4673
|
-
async function nudgeList({ repoRoot }) {
|
|
4674
|
-
const store = await readTodoStoreOrNull(repoRoot);
|
|
4675
|
-
const result = {
|
|
4676
|
-
schema: 'lattice.todo_nudge_result.v1', project_id: store?.project_id ?? null,
|
|
4677
|
-
lanes: store === null ? [] : projectTodoNudges(store, { declared: await declaredWitnessRows(repoRoot, store) }),
|
|
4678
|
-
result_digest: '',
|
|
4679
|
-
};
|
|
4680
|
-
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4681
|
-
return result;
|
|
4682
|
-
}
|
|
4683
|
-
|
|
4684
4749
|
/** The Store, or null where none exists yet (the BellTeam reads walk every chart directory). */
|
|
4685
4750
|
async function readTodoStoreOrNull(repoRoot) {
|
|
4686
4751
|
try { return await readTodoStore({ repoRoot }); }
|
|
@@ -4713,8 +4778,8 @@ async function blockerList({ repoRoot }) {
|
|
|
4713
4778
|
}
|
|
4714
4779
|
|
|
4715
4780
|
/** Open notices with their waiters (wait-design); an unreadable wait file is named, its waits read as none. */
|
|
4716
|
-
async function openNoticeView(repoRoot) {
|
|
4717
|
-
const store = await
|
|
4781
|
+
async function openNoticeView(repoRoot, env) {
|
|
4782
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
4718
4783
|
const declared = await declaredWitnessRows(repoRoot, store);
|
|
4719
4784
|
const stored = await readAllTodoNoticeWaits({ repoRoot });
|
|
4720
4785
|
// Readers return raw records: waits that ended since the file's last write are dropped here.
|
|
@@ -4726,8 +4791,8 @@ async function openNoticeView(repoRoot) {
|
|
|
4726
4791
|
return { store, notices, waitUnreadable: stored.unreadable };
|
|
4727
4792
|
}
|
|
4728
4793
|
|
|
4729
|
-
async function openNotices(repoRoot) {
|
|
4730
|
-
return (await openNoticeView(repoRoot)).notices;
|
|
4794
|
+
async function openNotices(repoRoot, env) {
|
|
4795
|
+
return (await openNoticeView(repoRoot, env)).notices;
|
|
4731
4796
|
}
|
|
4732
4797
|
|
|
4733
4798
|
/** lane -> notice_id -> [{waiting_digest, recipients}] from ack set records. */
|
|
@@ -4754,12 +4819,12 @@ function withAckState(notice, index) {
|
|
|
4754
4819
|
const noticeRecipients = (notice) => [...new Set([notice.lane, ...notice.waiting.map(({ agent }) => agent)])].sort();
|
|
4755
4820
|
|
|
4756
4821
|
/** A committed write is never undone for its notices: an unreadable projection says so and `notice list` recovers. */
|
|
4757
|
-
async function withNotices(repoRoot, result, before) {
|
|
4822
|
+
async function withNotices(repoRoot, result, before, env) {
|
|
4758
4823
|
if (result === null || typeof result !== 'object' || typeof result.result_digest !== 'string') return result;
|
|
4759
4824
|
let extra;
|
|
4760
4825
|
try {
|
|
4761
4826
|
if (before === null) throw new Error('notices_before_unreadable');
|
|
4762
|
-
const released = newTodoNotices(before, await openNotices(repoRoot));
|
|
4827
|
+
const released = newTodoNotices(before, await openNotices(repoRoot, env));
|
|
4763
4828
|
// An unreadable ack set only means nobody counts as covered yet: delivery repeats, nothing is lost.
|
|
4764
4829
|
const index = ackIndex(released.length === 0 ? []
|
|
4765
4830
|
: await readAllTodoNoticeAcks({ repoRoot }).then(({ acks }) => acks, () => []));
|
|
@@ -4785,8 +4850,8 @@ function noticeAckRefusal(error, lane) {
|
|
|
4785
4850
|
}
|
|
4786
4851
|
|
|
4787
4852
|
/** `todo notice list`: open notices, unacked unless asked; one unreadable ack file never hides the rest. */
|
|
4788
|
-
async function noticeList({ repoRoot, lane, includeAcked }) {
|
|
4789
|
-
const view = await openNoticeView(repoRoot);
|
|
4853
|
+
async function noticeList({ repoRoot, env, lane, includeAcked }) {
|
|
4854
|
+
const view = await openNoticeView(repoRoot, env);
|
|
4790
4855
|
const open = view.notices.filter((notice) => lane === null || notice.lane === lane);
|
|
4791
4856
|
const records = [];
|
|
4792
4857
|
const ackUnreadable = [];
|
|
@@ -4815,7 +4880,7 @@ async function noticeList({ repoRoot, lane, includeAcked }) {
|
|
|
4815
4880
|
|
|
4816
4881
|
/** `todo notice ack`: an id that is no longer open is reported as closed, never refused (nothing is left to ack). */
|
|
4817
4882
|
async function noticeAck({ repoRoot, env, lane, ids }) {
|
|
4818
|
-
const view = await openNoticeView(repoRoot);
|
|
4883
|
+
const view = await openNoticeView(repoRoot, env);
|
|
4819
4884
|
const laneNotices = view.notices.filter((notice) => notice.lane === lane);
|
|
4820
4885
|
const openIds = laneNotices.map(({ notice_id: id }) => id);
|
|
4821
4886
|
const open = new Set(openIds);
|
|
@@ -4841,7 +4906,7 @@ async function noticeAck({ repoRoot, env, lane, ids }) {
|
|
|
4841
4906
|
* gate: an already startable or finished T is answered with a state and nothing is written.
|
|
4842
4907
|
*/
|
|
4843
4908
|
async function noticeWait({ repoRoot, env, planKey, taskId, reason, cancel }) {
|
|
4844
|
-
const view = await openNoticeView(repoRoot);
|
|
4909
|
+
const view = await openNoticeView(repoRoot, env);
|
|
4845
4910
|
const { store } = view;
|
|
4846
4911
|
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
4847
4912
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
@@ -5213,7 +5278,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5213
5278
|
action = (repoRoot) => repairStoreEol({ repoRoot });
|
|
5214
5279
|
} else if ((argv.length === 1 && argv[0] === 'status')
|
|
5215
5280
|
|| (argv.length === 2 && argv[0] === 'status' && argv[1] === '--json')) {
|
|
5216
|
-
action = (repoRoot) => status({ repoRoot });
|
|
5281
|
+
action = (repoRoot) => status({ repoRoot, env });
|
|
5217
5282
|
} else if (argv.length === 3 && argv[0] === 'dashboard'
|
|
5218
5283
|
&& argv[1] === 'adopt' && argv[2] === '--json') {
|
|
5219
5284
|
action = (repoRoot) => adoptDashboardRoot({ repoRoot, env });
|
|
@@ -5230,7 +5295,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5230
5295
|
};
|
|
5231
5296
|
} else if (argv[0] === 'show' && readFlags(argv, ['show']) !== null) {
|
|
5232
5297
|
const flags = readFlags(argv, ['show']);
|
|
5233
|
-
action = (repoRoot) => todoDetail({ repoRoot, planKey: flags.plan, taskId: flags.task });
|
|
5298
|
+
action = (repoRoot) => todoDetail({ repoRoot, env, planKey: flags.plan, taskId: flags.task });
|
|
5234
5299
|
} else if ((argv.length === 1 && argv[0] === 'bindings')
|
|
5235
5300
|
|| (argv.length === 2 && argv[0] === 'bindings' && argv[1] === '--json')) {
|
|
5236
5301
|
action = (repoRoot) => bindings({ repoRoot, requestedPlanKey: null });
|
|
@@ -5242,7 +5307,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5242
5307
|
&& (argv.length === 2 || (argv.length === 3 && argv[2] === '--json'))) {
|
|
5243
5308
|
// Host display read (BellTeam module): a typed inconsistency is a state, never a refusal.
|
|
5244
5309
|
action = argv[1] === 'read'
|
|
5245
|
-
? async (repoRoot) => (
|
|
5310
|
+
? async (repoRoot) => displayRead(repoRoot, env)
|
|
5246
5311
|
: (repoRoot) => readTodoStoreDisplaySource({ repoRoot });
|
|
5247
5312
|
} else if (argv[0] === 'note' && argv[1] !== 'list') {
|
|
5248
5313
|
const flags = matchFlagCommand(argv, ['note'], NOTE_FLAG_SPEC);
|
|
@@ -5264,7 +5329,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5264
5329
|
&& matchFlagCommand(argv, ['notice', 'list'], TODO_FLAG_SPECS['notice list']) !== null) {
|
|
5265
5330
|
const flags = matchFlagCommand(argv, ['notice', 'list'], TODO_FLAG_SPECS['notice list']);
|
|
5266
5331
|
if (flags.lane === undefined || isNoticeLane(flags.lane)) {
|
|
5267
|
-
action = (repoRoot) => noticeList({ repoRoot, lane: flags.lane ?? null, includeAcked: flags['include-acked'] === true });
|
|
5332
|
+
action = (repoRoot) => noticeList({ repoRoot, env, lane: flags.lane ?? null, includeAcked: flags['include-acked'] === true });
|
|
5268
5333
|
}
|
|
5269
5334
|
} else if (argv[0] === 'notice' && argv[1] === 'ack'
|
|
5270
5335
|
&& matchFlagCommand(argv, ['notice', 'ack'], TODO_FLAG_SPECS['notice ack']) !== null) {
|
|
@@ -5273,8 +5338,6 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5273
5338
|
if (isNoticeLane(flags.lane) && ids.length > 0 && ids.every((id) => /^[0-9a-f]{64}$/u.test(id))) {
|
|
5274
5339
|
action = (repoRoot) => noticeAck({ repoRoot, env, lane: flags.lane, ids });
|
|
5275
5340
|
}
|
|
5276
|
-
} else if (argv[0] === 'nudge' && matchFlagCommand(argv, ['nudge'], TODO_FLAG_SPECS.nudge) !== null) {
|
|
5277
|
-
action = (repoRoot) => nudgeList({ repoRoot });
|
|
5278
5341
|
} else if (argv[0] === 'blockers' && matchFlagCommand(argv, ['blockers'], TODO_FLAG_SPECS.blockers) !== null) {
|
|
5279
5342
|
action = (repoRoot) => blockerList({ repoRoot });
|
|
5280
5343
|
} else if (argv[0] === 'wait' && matchFlagCommand(argv, ['wait'], TODO_FLAG_SPECS.wait) !== null) {
|
|
@@ -5303,14 +5366,14 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5303
5366
|
&& dependencyFlags(argv) !== null) {
|
|
5304
5367
|
const flags = dependencyFlags(argv);
|
|
5305
5368
|
action = (repoRoot) => dependencyConnect({
|
|
5306
|
-
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5369
|
+
repoRoot, env, fromProjectId: flags['from-project'] ?? null, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5307
5370
|
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
5308
5371
|
});
|
|
5309
5372
|
} else if (argv[0] === 'dependency' && argv[1] === 'disconnect'
|
|
5310
5373
|
&& dependencyFlags(argv) !== null) {
|
|
5311
5374
|
const flags = dependencyFlags(argv);
|
|
5312
5375
|
action = (repoRoot) => dependencyDisconnect({
|
|
5313
|
-
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5376
|
+
repoRoot, env, fromProjectId: flags['from-project'] ?? null, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5314
5377
|
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
5315
5378
|
});
|
|
5316
5379
|
} else if (argv[0] === 'independence' && argv[1] === 'compile') {
|
|
@@ -5381,7 +5444,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5381
5444
|
const flags = matchFlagCommand(argv, ['independence', 'witness', 'declare'],
|
|
5382
5445
|
TODO_FLAG_SPECS['independence witness declare']);
|
|
5383
5446
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
5384
|
-
action = (repoRoot) => witnessDeclare({ repoRoot, planKey: flags.plan, flags });
|
|
5447
|
+
action = (repoRoot) => witnessDeclare({ repoRoot, env, planKey: flags.plan, flags });
|
|
5385
5448
|
}
|
|
5386
5449
|
} else if (argv[0] === 'independence' && argv[1] === 'witness' && argv[2] === 'scaffold') {
|
|
5387
5450
|
const flags = matchFlagCommand(argv, ['independence', 'witness', 'scaffold'],
|
|
@@ -5666,11 +5729,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5666
5729
|
if (writesTodoStore(argv)) {
|
|
5667
5730
|
await ensureActiveProjectDashboard({ repoRoot, env, stderr });
|
|
5668
5731
|
}
|
|
5669
|
-
const before = releasesTasks(argv) ? await openNotices(repoRoot).catch(() => null) : null;
|
|
5732
|
+
const before = releasesTasks(argv) ? await openNotices(repoRoot, env).catch(() => null) : null;
|
|
5670
5733
|
const written = atomicCommit
|
|
5671
5734
|
? await commitTodoStoreMutation({ repoRoot, argv, action, env })
|
|
5672
5735
|
: await action(repoRoot);
|
|
5673
|
-
const result = releasesTasks(argv) ? await withNotices(repoRoot, written, before) : written;
|
|
5736
|
+
const result = releasesTasks(argv) ? await withNotices(repoRoot, written, before, env) : written;
|
|
5674
5737
|
if (result !== null) stdout.write(`${plainVerify ? verifyVerdictLine(result) : JSON.stringify(result)}\n`);
|
|
5675
5738
|
return 0;
|
|
5676
5739
|
} catch (error) {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Cross-chart predecessors (xchart, docs/architecture/dfd-plan-revise.md#cross-chart-dependency-xchart-2026-11-13):
|
|
2
|
+
// a ledger edge whose `from` is a task of another chart (another project's Store under LATTICE_CHARTS_ROOT).
|
|
3
|
+
// Plan reads the other chart read-only; an unreadable one only keeps its waiters waiting.
|
|
4
|
+
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
import { createTodoReadiness } from './todo-readiness.mjs';
|
|
8
|
+
import { isFinishedTodoTaskState, projectTodoCrossPlanDependencies } from './todo-store-view.mjs';
|
|
9
|
+
import { readTodoStoreReadOnly, TodoStoreError } from './todo-store.mjs';
|
|
10
|
+
|
|
11
|
+
export const TODO_CHARTS_ROOT_ENV = 'LATTICE_CHARTS_ROOT';
|
|
12
|
+
|
|
13
|
+
/** Live ledger edges of `store` whose predecessor is on another chart. */
|
|
14
|
+
export function externalTodoDependencies(store) {
|
|
15
|
+
return projectTodoCrossPlanDependencies(store.members)
|
|
16
|
+
.filter(({ from }) => from.project_id !== store.project_id);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The other chart's Store, or a reason it cannot be read: `{store}` | `{reason, path}`. Never throws. */
|
|
20
|
+
async function readChart(env, projectId) {
|
|
21
|
+
const root = env?.[TODO_CHARTS_ROOT_ENV];
|
|
22
|
+
if (typeof root !== 'string' || root === '') return { reason: 'charts_root_unset', path: null };
|
|
23
|
+
// project ids are identifiers (no separators), so the join stays inside the root.
|
|
24
|
+
const chartPath = path.join(path.resolve(root), projectId);
|
|
25
|
+
try {
|
|
26
|
+
const store = await readTodoStoreReadOnly({ repoRoot: chartPath });
|
|
27
|
+
// A chart that says it is another project is the wrong target, not this one.
|
|
28
|
+
return store.project_id === projectId ? { store } : { reason: 'chart_unreadable', path: chartPath };
|
|
29
|
+
} catch {
|
|
30
|
+
return { reason: 'chart_unreadable', path: chartPath };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Connect-time read: the other chart's Store, or a refusal that names the env var or the chart. */
|
|
35
|
+
export async function readTodoExternalChart(env, projectId) {
|
|
36
|
+
const chart = await readChart(env, projectId);
|
|
37
|
+
if (chart.store !== undefined) return chart.store;
|
|
38
|
+
if (chart.reason === 'charts_root_unset') {
|
|
39
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'charts_root_unset', undefined, {
|
|
40
|
+
project_id: projectId,
|
|
41
|
+
next_action: `Set ${TODO_CHARTS_ROOT_ENV} to the directory whose children are chart directories named by`
|
|
42
|
+
+ ` project id (${projectId} is read from <${TODO_CHARTS_ROOT_ENV}>/${projectId}/.lattice), then connect again.`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'chart_unreadable', undefined, {
|
|
46
|
+
project_id: projectId, path: chart.path,
|
|
47
|
+
next_action: `No readable Lattice chart for project ${projectId} at ${chart.path}; check the project id`
|
|
48
|
+
+ ` (\`lattice status --json\` in that chart) and ${TODO_CHARTS_ROOT_ENV}.`,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function taskTrigger(member, taskId) {
|
|
53
|
+
const event = member.journal.events.findLast((entry) => entry.task_id === taskId);
|
|
54
|
+
return event === undefined ? null
|
|
55
|
+
: { kind: event.kind, event_digest: event.event_digest, recorded_at: event.recorded_at, actor: event.actor ?? null };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The states of every external predecessor of `store`, one read per other project:
|
|
60
|
+
* `{external_tasks, findings}`; nothing is read when there is no external edge.
|
|
61
|
+
*/
|
|
62
|
+
export async function readTodoExternalTasks(store, env) {
|
|
63
|
+
const dependencies = externalTodoDependencies(store);
|
|
64
|
+
const charts = new Map();
|
|
65
|
+
for (const { from } of dependencies) {
|
|
66
|
+
if (!charts.has(from.project_id)) charts.set(from.project_id, await readChart(env, from.project_id));
|
|
67
|
+
}
|
|
68
|
+
const tasks = new Map();
|
|
69
|
+
const findings = [];
|
|
70
|
+
for (const dependency of dependencies) {
|
|
71
|
+
const { from } = dependency;
|
|
72
|
+
const chart = charts.get(from.project_id);
|
|
73
|
+
const member = chart.store?.members.find(({ plan }) => plan.plan_key === from.plan_key);
|
|
74
|
+
const state = member?.tasks.find(({ task_id: id }) => id === from.task_id);
|
|
75
|
+
const reason = chart.store === undefined ? chart.reason : state === undefined ? 'endpoint_missing' : null;
|
|
76
|
+
if (reason !== null) {
|
|
77
|
+
findings.push({ owner_plan_key: dependency.to.plan_key, event_digest: dependency.event_digest,
|
|
78
|
+
side: 'from', ref: structuredClone(from), reason });
|
|
79
|
+
}
|
|
80
|
+
tasks.set(`${from.project_id}\0${from.plan_key}\0${from.task_id}`, {
|
|
81
|
+
project_id: from.project_id, plan_key: from.plan_key, task_id: from.task_id,
|
|
82
|
+
status: state?.status ?? null, finished: isFinishedTodoTaskState(state), reason,
|
|
83
|
+
trigger: state === undefined ? null : taskTrigger(member, from.task_id),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return { external_tasks: [...tasks.values()], findings };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** `store` plus `external_tasks` and their findings, so every readiness reader sees one predicate. */
|
|
90
|
+
export async function withTodoExternalTasks(store, env) {
|
|
91
|
+
if (store.external_tasks !== undefined || externalTodoDependencies(store).length === 0) return store;
|
|
92
|
+
const { external_tasks: externalTasks, findings } = await readTodoExternalTasks(store, env);
|
|
93
|
+
return { ...store, external_tasks: externalTasks,
|
|
94
|
+
cross_plan_findings: [...(store.cross_plan_findings ?? []), ...findings] };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Connect-time cycle check through readable charts: walk `from`'s predecessors (in-chart and cross-chart) from
|
|
99
|
+
* `fromStore`; reaching `to` closes a cycle. Returns the closed path (from … to) or null. Unreadable charts end
|
|
100
|
+
* their branch (a cycle nobody can see is not refused).
|
|
101
|
+
*/
|
|
102
|
+
export async function externalCycle({ env, fromStore, from, to, localStore }) {
|
|
103
|
+
const key = (ref) => `${ref.project_id}\0${ref.plan_key}\0${ref.task_id}`;
|
|
104
|
+
const stores = new Map([[localStore.project_id, localStore], [fromStore.project_id, fromStore]]);
|
|
105
|
+
const target = key(to);
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const walk = async (ref, trail) => {
|
|
108
|
+
if (key(ref) === target) return [...trail, ref];
|
|
109
|
+
if (seen.has(key(ref))) return null;
|
|
110
|
+
seen.add(key(ref));
|
|
111
|
+
if (!stores.has(ref.project_id)) stores.set(ref.project_id, (await readChart(env, ref.project_id)).store ?? null);
|
|
112
|
+
const store = stores.get(ref.project_id);
|
|
113
|
+
if (store === null) return null;
|
|
114
|
+
const readiness = createTodoReadiness(store);
|
|
115
|
+
for (const pred of readiness.prerequisiteRefs(readiness.key(ref)).tasks) {
|
|
116
|
+
const found = await walk({ project_id: pred.project_id ?? store.project_id, plan_key: pred.plan_key,
|
|
117
|
+
task_id: pred.task_id }, [...trail, ref]);
|
|
118
|
+
if (found !== null) return found;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
const closed = await walk({ project_id: from.project_id, plan_key: from.plan_key, task_id: from.task_id }, []);
|
|
123
|
+
return closed === null ? null : [to, ...closed.slice(0, -1).reverse(), to]
|
|
124
|
+
.map(({ project_id: projectId, plan_key: planKey, task_id: taskId }) => ({ project_id: projectId, plan_key: planKey, task_id: taskId }));
|
|
125
|
+
}
|
package/src/todo-notices.mjs
CHANGED
|
@@ -59,6 +59,8 @@ function noticeSummary(planKey, task, waiting) {
|
|
|
59
59
|
export function projectTodoNotices(store, { lane = null, declared = () => true, waits = [] } = {}) {
|
|
60
60
|
const readiness = createTodoReadiness(store);
|
|
61
61
|
const members = new Map(store.members.map((member) => [member.plan.plan_key, member]));
|
|
62
|
+
const external = new Map((store.external_tasks ?? []).map((entry) => [
|
|
63
|
+
`${entry.project_id}\0${entry.plan_key}\0${entry.task_id}`, entry]));
|
|
62
64
|
const notices = [];
|
|
63
65
|
for (const ready of projectTodoStatus(store, TODO_STATUS_DISPATCH_ONLY).next_ready) {
|
|
64
66
|
const member = members.get(ready.plan_key);
|
|
@@ -67,6 +69,12 @@ export function projectTodoNotices(store, { lane = null, declared = () => true,
|
|
|
67
69
|
const refs = readiness.prerequisiteRefs(readiness.key({ ...member.plan, ...task }));
|
|
68
70
|
const triggers = [];
|
|
69
71
|
for (const ref of refs.tasks) {
|
|
72
|
+
if (ref.project_id !== undefined) {
|
|
73
|
+
// xchart: the done was written in the other chart; its latest event is read there (withTodoExternalTasks).
|
|
74
|
+
const trigger = external.get(`${ref.project_id}\0${ref.plan_key}\0${ref.task_id}`)?.trigger ?? null;
|
|
75
|
+
if (trigger !== null) triggers.push({ project_id: ref.project_id, plan_key: ref.plan_key, task_id: ref.task_id, ...trigger });
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
70
78
|
const event = latestEvent(members.get(ref.plan_key), (entry) => entry.task_id === ref.task_id);
|
|
71
79
|
if (event !== null) triggers.push(triggerOf(members.get(ref.plan_key), event, { task_id: ref.task_id }));
|
|
72
80
|
}
|
package/src/todo-readiness.mjs
CHANGED
|
@@ -50,9 +50,21 @@ export function createTodoReadiness(store) {
|
|
|
50
50
|
acceptanceIncoming.set(key, new Set());
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
// xchart: predecessors on other charts, as their chart reports them (`withTodoExternalTasks`); never phase-gated.
|
|
54
|
+
for (const entry of store.external_tasks ?? []) {
|
|
55
|
+
nodes.set(taskKey(entry), { status: entry.status, task_id: entry.task_id, finished: entry.finished === true,
|
|
56
|
+
schema: null, plan_key: entry.plan_key, project_id: entry.project_id, phase_id: null, reason: entry.reason });
|
|
57
|
+
}
|
|
58
|
+
// An external edge whose state was not loaded waits (fail closed), named `chart_not_read`.
|
|
59
|
+
const external = new Map();
|
|
60
|
+
const predecessorNode = (source) => nodes.get(source) ?? (external.has(source)
|
|
61
|
+
? { ...external.get(source), status: null, finished: false, schema: null, reason: 'chart_not_read' } : undefined);
|
|
53
62
|
const connect = (from, to) => {
|
|
54
63
|
const source = taskKey(from);
|
|
55
64
|
const target = taskKey(to);
|
|
65
|
+
if (from.project_id !== to.project_id) {
|
|
66
|
+
external.set(source, { project_id: from.project_id, plan_key: from.plan_key, task_id: from.task_id });
|
|
67
|
+
}
|
|
56
68
|
incoming.get(target)?.add(source);
|
|
57
69
|
outgoing.get(source)?.add(target);
|
|
58
70
|
};
|
|
@@ -85,7 +97,7 @@ export function createTodoReadiness(store) {
|
|
|
85
97
|
|
|
86
98
|
function prerequisites(key) {
|
|
87
99
|
// u03 A24: 消えた端点(Storeのendpoint_missing finding)は後続を止めない。Store replayも同じ規則。
|
|
88
|
-
const predecessors = [...(incoming.get(key) ?? [])].map(
|
|
100
|
+
const predecessors = [...(incoming.get(key) ?? [])].map(predecessorNode)
|
|
89
101
|
.filter((node) => node !== undefined);
|
|
90
102
|
const unfinished = predecessors.filter((node) => node.finished !== true);
|
|
91
103
|
const unreadyPhases = predecessors.filter((node) => !dependencyPhaseReady(node, nodes.get(key)));
|
|
@@ -107,7 +119,7 @@ export function createTodoReadiness(store) {
|
|
|
107
119
|
cause,
|
|
108
120
|
// a12: a refusal names what blocks, not only why.
|
|
109
121
|
blocking: cause === 'predecessor_unfinished'
|
|
110
|
-
? { blocking_tasks: unfinished.map(
|
|
122
|
+
? { blocking_tasks: unfinished.map(blockingTask).sort(byRef) }
|
|
111
123
|
: cause === 'acceptance_edge'
|
|
112
124
|
? { blocking_phases: uniqueRefs(blockingPhases).map((phase) => ({ ...phase })).sort(byRef) } : {},
|
|
113
125
|
};
|
|
@@ -133,8 +145,10 @@ export function createTodoReadiness(store) {
|
|
|
133
145
|
/** notice-impl: what a task waits on — predecessor tasks, phases whose accept it needs, and its own phase. */
|
|
134
146
|
function prerequisiteRefs(key) {
|
|
135
147
|
const node = nodes.get(key);
|
|
136
|
-
const tasks = [...(incoming.get(key) ?? [])].map(
|
|
137
|
-
.filter((pred) => pred !== undefined).map(({ plan_key, task_id }) => (
|
|
148
|
+
const tasks = [...(incoming.get(key) ?? [])].map(predecessorNode)
|
|
149
|
+
.filter((pred) => pred !== undefined).map(({ project_id: projectId, plan_key, task_id }) => (
|
|
150
|
+
external.has(taskKey({ project_id: projectId, plan_key, task_id }))
|
|
151
|
+
? { project_id: projectId, plan_key, task_id } : { plan_key, task_id }));
|
|
138
152
|
const phaseRefs = [...(acceptanceIncoming.get(key) ?? [])].map((source) => phases.get(source))
|
|
139
153
|
.filter((phase) => phase !== undefined).map(({ plan_key, phase_id }) => ({ plan_key, phase_id }));
|
|
140
154
|
for (const source of incoming.get(key) ?? []) {
|
|
@@ -172,7 +186,13 @@ export function createTodoReadiness(store) {
|
|
|
172
186
|
};
|
|
173
187
|
}
|
|
174
188
|
|
|
175
|
-
const refId = (ref) => `${ref.plan_key}\0${ref.task_id ?? ref.phase_id}`;
|
|
189
|
+
const refId = (ref) => `${ref.project_id ?? ''}\0${ref.plan_key}\0${ref.task_id ?? ref.phase_id}`;
|
|
190
|
+
|
|
191
|
+
/** a12 blocking entry; an external predecessor also names its project and why it waits (null when readable). */
|
|
192
|
+
function blockingTask({ project_id: projectId, plan_key, task_id, status, reason }) {
|
|
193
|
+
return projectId === undefined ? { plan_key, task_id, status }
|
|
194
|
+
: { project_id: projectId, plan_key, task_id, status, reason: reason ?? null };
|
|
195
|
+
}
|
|
176
196
|
function byRef(left, right) {
|
|
177
197
|
return refId(left) < refId(right) ? -1 : refId(left) > refId(right) ? 1 : 0;
|
|
178
198
|
}
|
package/src/todo-status.mjs
CHANGED
|
@@ -330,7 +330,7 @@ function crossPlanFindingEntry(value) {
|
|
|
330
330
|
|| !isTodoIdentifier(value.owner_plan_key)
|
|
331
331
|
|| !(value.event_digest === null || isTodoDigest(value.event_digest))
|
|
332
332
|
|| !['from', 'to'].includes(value.side)
|
|
333
|
-
|| !['binding_stale', 'endpoint_missing'].includes(value.reason)) return false;
|
|
333
|
+
|| !['binding_stale', 'endpoint_missing', 'charts_root_unset', 'chart_unreadable'].includes(value.reason)) return false;
|
|
334
334
|
const { ref } = value;
|
|
335
335
|
const common = (keys) => exactRecord(ref, keys) && isTodoIdentifier(ref.project_id)
|
|
336
336
|
&& isTodoIdentifier(ref.plan_key)
|
|
@@ -534,6 +534,8 @@ function buildTodoGraph(readModel) {
|
|
|
534
534
|
// active plan topologyは追記改変しない。開発中に接続したplan-scoped edgeを同じincomingへ
|
|
535
535
|
// 合成することで、projectTodoStatusとcomputeReadyFrontierが同じ待機判定を即座に読む。
|
|
536
536
|
for (const dependency of projectTodoCrossPlanDependencies(members)) {
|
|
537
|
+
// xchart: a predecessor on another chart is not a node here; readiness (external_tasks) decides next_ready.
|
|
538
|
+
if (dependency.from.project_id !== dependency.to.project_id) continue;
|
|
537
539
|
addPredecessor(dependency.from, dependency.to);
|
|
538
540
|
}
|
|
539
541
|
|
package/src/todo-store.mjs
CHANGED
|
@@ -1032,6 +1032,8 @@ function validateMergedGraph(members, crossPlanDependencies = projectTodoCrossPl
|
|
|
1032
1032
|
const owner = members.find(({ plan }) => plan.project_id === dependency.to.project_id
|
|
1033
1033
|
&& plan.plan_key === dependency.to.plan_key);
|
|
1034
1034
|
if (owner === undefined) fail('STORE_INCONSISTENT', 'cross_plan_dependency_owner_missing');
|
|
1035
|
+
// xchart S2: a predecessor on another chart is Plan's node (read there); no finding, no adjacency here.
|
|
1036
|
+
if (dependency.from.project_id !== owner.plan.project_id) continue;
|
|
1035
1037
|
const digest = dependency.event_digest ?? null;
|
|
1036
1038
|
const from = bind(dependency.from, owner.plan, digest, 'from');
|
|
1037
1039
|
const to = bind(dependency.to, owner.plan, digest, 'to');
|
|
@@ -1077,9 +1079,14 @@ function crossPlanDependencyTask(store, ref) {
|
|
|
1077
1079
|
return { member, task };
|
|
1078
1080
|
}
|
|
1079
1081
|
|
|
1080
|
-
|
|
1082
|
+
/**
|
|
1083
|
+
* xchart S3: only `todo dependency connect` (appendTodoEvent, `foreignFrom`) may record a predecessor on another
|
|
1084
|
+
* chart; Plan checked it there just before. Genesis, import and connectionOnly keep refusing a foreign from.
|
|
1085
|
+
*/
|
|
1086
|
+
function validateCrossPlanDependencyTransition(store, owner, input, { foreignFrom = false } = {}) {
|
|
1081
1087
|
const { from, to } = input.payload;
|
|
1082
|
-
|
|
1088
|
+
const foreign = from.project_id !== store.project_id;
|
|
1089
|
+
if ((foreign && !foreignFrom) || to.project_id !== store.project_id) {
|
|
1083
1090
|
fail('DEPENDENCY_INVALID', 'dependency_project_mismatch');
|
|
1084
1091
|
}
|
|
1085
1092
|
// 同一plan内の後追い接続も受ける(2026-08-25 オーナー裁定)。「工程の線を誤ったので足す」という
|
|
@@ -1097,7 +1104,7 @@ function validateCrossPlanDependencyTransition(store, owner, input) {
|
|
|
1097
1104
|
edge.from.task_id === from.task_id && edge.to.task_id === to.task_id))) {
|
|
1098
1105
|
fail('DEPENDENCY_EXISTS', 'dependency_already_in_plan', { from, to });
|
|
1099
1106
|
}
|
|
1100
|
-
|
|
1107
|
+
if (!foreign) crossPlanDependencyTask(store, from);
|
|
1101
1108
|
const target = crossPlanDependencyTask(store, to);
|
|
1102
1109
|
// A completed source already satisfies the prerequisite. Keep the existing
|
|
1103
1110
|
// completion record as the proof instead of creating a second ledger entry.
|
|
@@ -1850,6 +1857,16 @@ async function repairCrossPlanBindings(repoRoot, store, { assertHeld, actor, rec
|
|
|
1850
1857
|
return repairs;
|
|
1851
1858
|
}
|
|
1852
1859
|
|
|
1860
|
+
/**
|
|
1861
|
+
* xchart S1: read another chart without touching it: the non-recovering view (no lock, no recovery, no write).
|
|
1862
|
+
* Throws where that chart's own writer must recover (manifest_journal_head_mismatch after the stable-read attempts,
|
|
1863
|
+
* cross_plan_import_recovery_required, source_cutover_recovery_required) and STORE_UNINITIALIZED; Plan reads any
|
|
1864
|
+
* throw as "that chart is unreadable" for its edges only.
|
|
1865
|
+
*/
|
|
1866
|
+
export async function readTodoStoreReadOnly({ repoRoot }) {
|
|
1867
|
+
return readStoreStableWith({ repoRoot }, readTodoStoreView);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1853
1870
|
export async function readTodoStoreStable(options = {}) {
|
|
1854
1871
|
return readStoreStableWith(options, readTodoStore);
|
|
1855
1872
|
}
|
|
@@ -2409,7 +2426,7 @@ export async function appendTodoEvent(options = {}) {
|
|
|
2409
2426
|
// 「作業が進んだ」の意味であり、方式選択や依存接続でそこを動かすと意味がずれる。
|
|
2410
2427
|
if (TODO_PLAN_SCOPED_EVENT_KINDS.includes(options.event.kind)) {
|
|
2411
2428
|
if (options.event.kind === 'cross_plan_dependency') {
|
|
2412
|
-
validateCrossPlanDependencyTransition(store, member, options.event);
|
|
2429
|
+
validateCrossPlanDependencyTransition(store, member, options.event, { foreignFrom: true });
|
|
2413
2430
|
}
|
|
2414
2431
|
if (options.event.kind === 'cross_plan_dependency_removed') {
|
|
2415
2432
|
const digest = options.event.payload.target_event_digest;
|
package/src/todo-nudges.mjs
DELETED
|
@@ -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
|
-
}
|