@quolu/lattice 0.98.0 → 0.100.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 -6
- package/src/plan-backchain.mjs +12 -15
- package/src/project-cli.mjs +6 -4
- package/src/todo-cli.mjs +158 -45
- package/src/todo-contracts.mjs +13 -0
- package/src/todo-external.mjs +125 -0
- package/src/todo-note-store.mjs +32 -24
- 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 +231 -33
- package/src/todo-trees.mjs +71 -0
- package/src/todo-version-memo.mjs +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.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
|
@@ -139,9 +139,10 @@ Write commands:
|
|
|
139
139
|
evidence anchor [--json] # 既存の証拠をgcから守る印(refs/lattice/evidence/<oid>)を付ける。commit済みにはならない
|
|
140
140
|
# done状態と完了時刻を維持し、最新doneへ追記eventで証拠を再束縛する
|
|
141
141
|
start --plan <key> --task <id> --rebind --reason <text> # 改訂でcarryされたin-progressへ現版のstart束縛を積み直す(ADR 0191)
|
|
142
|
-
dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
143
|
-
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>
|
|
144
144
|
# 開発中に発見した依存を明示接続する。同一plan内の辺はplan本体を軽い改訂で書き換え(plan_versionが変わる)、plan跨ぎは台帳に積む。依存の自動推定は行わない
|
|
145
|
+
# --from-project = 別の工程表(別プロジェクト)の工程を前工程にする。LATTICE_CHARTS_ROOT/<project_id>/.lattice を読むだけで書かない。読めない間は待ちのまま
|
|
145
146
|
independence mode --plan <key> --set <witness|conversation|enforced> --reason <text>
|
|
146
147
|
# enforced = witness+未宣言・古い宣言・衝突・参照なしdone・heavy段階の監査なし閉じを止める(ADR 0200)
|
|
147
148
|
# このplanの調整方式(witness検証で並列するか、会話で調整するか)を記録する
|
|
@@ -352,11 +353,11 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
352
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',
|
|
353
354
|
'todo evidence promote': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
|
354
355
|
'todo dependency': [
|
|
355
|
-
'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
356
|
-
'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>',
|
|
357
358
|
].join('\n lattice '),
|
|
358
|
-
'todo dependency connect': 'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
359
|
-
'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>',
|
|
360
361
|
'todo split': 'todo split --plan <key> --input <file>',
|
|
361
362
|
'todo revise': 'todo revise --plan <key> --input <file> | --schema --json',
|
|
362
363
|
'todo revise-phase': 'todo revise-phase --plan <key> --input <file> | --schema --json',
|
package/src/plan-backchain.mjs
CHANGED
|
@@ -603,26 +603,23 @@ export function carriedStartActors(member) {
|
|
|
603
603
|
export async function rebindCarriedWork({ repoRoot, planKey, env,
|
|
604
604
|
reason = 'ゴール変更後のplan versionへ作業中ToDoを結び直す',
|
|
605
605
|
failureCode = 'BACKCHAIN_REBIND_PENDING', carriedActors = new Map() }) {
|
|
606
|
+
// perf-rebind: one store read for every carried task (was 5 full passes per task through rebindStart).
|
|
606
607
|
const store = await readTodoStore({ repoRoot });
|
|
607
608
|
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
608
|
-
const rebound =
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
reason, actor: carriedActors.get(state.task_id) ?? null });
|
|
617
|
-
} catch (error) {
|
|
609
|
+
const rebound = member.tasks.filter(({ status, task_id: taskId }) => status === 'in-progress'
|
|
610
|
+
&& !member.journal.events.some((event) => event.kind === 'start'
|
|
611
|
+
&& event.task_id === taskId && event.payload?.start_mode !== 'historical_import'))
|
|
612
|
+
.map(({ task_id: taskId }) => taskId);
|
|
613
|
+
const { rebindCarriedStarts } = await import('./todo-cli.mjs');
|
|
614
|
+
await rebindCarriedStarts({ repoRoot, env, store, planKey, reason,
|
|
615
|
+
tasks: rebound.map((taskId) => ({ task_id: taskId, actor: carriedActors.get(taskId) ?? null })),
|
|
616
|
+
onFailure: (taskId, error) => {
|
|
618
617
|
throw new TodoStoreError(failureCode, 'carried_task_rebind_failed', undefined, {
|
|
619
|
-
task_id:
|
|
618
|
+
task_id: taskId, plan_version: member.plan.plan_version,
|
|
620
619
|
cause_code: error?.code ?? 'unknown',
|
|
621
|
-
next_action: `lattice todo start --plan ${planKey} --task ${
|
|
620
|
+
next_action: `lattice todo start --plan ${planKey} --task ${taskId} --rebind --reason <text>`,
|
|
622
621
|
});
|
|
623
|
-
}
|
|
624
|
-
rebound.push(state.task_id);
|
|
625
|
-
}
|
|
622
|
+
} });
|
|
626
623
|
return rebound;
|
|
627
624
|
}
|
|
628
625
|
|
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,6 +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';
|
|
177
|
+
import { projectTodoTrees } from './todo-trees.mjs';
|
|
174
178
|
import { projectTodoBlockers, todoBlockerKey } from './todo-blockers.mjs';
|
|
175
179
|
import {
|
|
176
180
|
ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
|
|
@@ -330,7 +334,7 @@ const REASON_FLAG_SPEC = Object.freeze({ known: ['plan', 'task', 'reason'], requ
|
|
|
330
334
|
const PHASE_REASON_FLAG_SPEC = Object.freeze({ known: ['plan', 'phase', 'reason'], required: ['plan', 'phase', 'reason'] });
|
|
331
335
|
const NOTE_FLAG_SPEC = Object.freeze({ known: ['plan', 'task', 'message', 'input', 'supersedes'], required: ['plan'] });
|
|
332
336
|
const DEPENDENCY_FLAG_SPEC = Object.freeze({
|
|
333
|
-
known: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
337
|
+
known: ['from-project', 'from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
334
338
|
required: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
335
339
|
});
|
|
336
340
|
// a18: one spec per write command is both its parser and the explanation of its refusal.
|
|
@@ -406,7 +410,8 @@ function repairedCommand(head, spec, flags) {
|
|
|
406
410
|
/** `dependency connect|disconnect` flags by name (order-free), or null. */
|
|
407
411
|
function dependencyFlags(argv) {
|
|
408
412
|
const flags = matchFlagCommand(argv, argv.slice(0, 2), DEPENDENCY_FLAG_SPEC);
|
|
409
|
-
return flags !== null && IDENTIFIER_FLAGS.slice(3).every((name) => isTodoIdentifier(flags[name]))
|
|
413
|
+
return flags !== null && IDENTIFIER_FLAGS.slice(3).every((name) => isTodoIdentifier(flags[name]))
|
|
414
|
+
&& (flags['from-project'] === undefined || isTodoIdentifier(flags['from-project'])) ? flags : null;
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
/** a28: a read command's flags by name (order-free, --json optional) with valid identifiers, or null. */
|
|
@@ -972,12 +977,22 @@ function reopenAdvisory(plan, phases, taskId) {
|
|
|
972
977
|
};
|
|
973
978
|
}
|
|
974
979
|
|
|
980
|
+
/** The prospective validator with `external` (xchart predecessor states) bound into the locked store. */
|
|
981
|
+
function externalValidator(external) {
|
|
982
|
+
return external.length === 0 ? validateProspectiveEvent
|
|
983
|
+
: (input) => validateProspectiveEvent({ ...input, store: { ...input.store, external_tasks: external } });
|
|
984
|
+
}
|
|
985
|
+
|
|
975
986
|
async function mutate({
|
|
976
987
|
repoRoot, env, planKey, taskId, kind, payload, evidenceRef, evidenceMessage = null,
|
|
977
988
|
advisory = null, noteContext = null, structureContext = null, featureContext = null,
|
|
978
|
-
testResultRef = null, actor: carriedActor = null,
|
|
989
|
+
testResultRef = null, actor: carriedActor = null, externalTasks = null,
|
|
979
990
|
}) {
|
|
980
991
|
const actor = carriedActor ?? resolveTodoActor(env);
|
|
992
|
+
// xchart: start and authored done check predecessors on other charts too, read before the lock.
|
|
993
|
+
const external = externalTasks ?? (kind === 'start' || (kind === 'done' && payload === 'authored')
|
|
994
|
+
? (await readTodoExternalTasks(await readTodoStore({ repoRoot }), env)).external_tasks : []);
|
|
995
|
+
const validator = externalValidator(external);
|
|
981
996
|
const evidence = evidenceRef === null && evidenceMessage === null
|
|
982
997
|
? null
|
|
983
998
|
: await resolveDoneEvidence({
|
|
@@ -1005,7 +1020,7 @@ async function mutate({
|
|
|
1005
1020
|
eventPayload = { done_mode: 'evidence_promotion', evidence };
|
|
1006
1021
|
}
|
|
1007
1022
|
const { event, snapshot, plan, phases } = await appendTodoEvent({
|
|
1008
|
-
validateProspectiveEvent,
|
|
1023
|
+
validateProspectiveEvent: validator,
|
|
1009
1024
|
repoRoot,
|
|
1010
1025
|
writer: createTodoStoreWriter({ caller: 'g5-authoring' }),
|
|
1011
1026
|
planKey,
|
|
@@ -1389,10 +1404,26 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
1389
1404
|
};
|
|
1390
1405
|
}
|
|
1391
1406
|
|
|
1407
|
+
/**
|
|
1408
|
+
* xchart: the display envelope plus `external_tasks`, so a host computing readiness from it sees other charts too;
|
|
1409
|
+
* a100: plus `trees`, each task tree and its size, so the host never computes the graph.
|
|
1410
|
+
*/
|
|
1411
|
+
async function displayRead(repoRoot, env) {
|
|
1412
|
+
const display = await readTodoStoreForDisplay({ repoRoot });
|
|
1413
|
+
const externalTasks = display.store ? (await readTodoExternalTasks(display.store, env)).external_tasks : [];
|
|
1414
|
+
return { schema: 'lattice.todo_display_read_result.v1', ...display, external_tasks: externalTasks,
|
|
1415
|
+
trees: display.store ? projectTodoTrees(display.store) : [] };
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/** xchart: the Store plus its external predecessors' states; every readiness reader reads through this. */
|
|
1419
|
+
async function readTodoStoreForReadiness({ repoRoot, env = process.env }) {
|
|
1420
|
+
return withTodoExternalTasks(await readTodoStore({ repoRoot }), env);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1392
1423
|
async function startTask({
|
|
1393
1424
|
repoRoot, env, planKey, taskId, overrideReason,
|
|
1394
1425
|
}) {
|
|
1395
|
-
const store = await
|
|
1426
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
1396
1427
|
// startはready判定にしかprojectionを使わず、resultを出力しない。
|
|
1397
1428
|
const projection = projectTodoStatus(store, TODO_STATUS_DISPATCH_ONLY);
|
|
1398
1429
|
const readyTask = projection.next_ready.find((task) => (
|
|
@@ -1461,7 +1492,7 @@ async function startTask({
|
|
|
1461
1492
|
}
|
|
1462
1493
|
return mutate({ repoRoot, env, planKey, taskId: resolvedTaskId, kind: 'start',
|
|
1463
1494
|
payload: { override_reason: overrideReason }, evidenceRef: null, advisory, noteContext,
|
|
1464
|
-
structureContext, featureContext });
|
|
1495
|
+
structureContext, featureContext, externalTasks: store.external_tasks ?? [] });
|
|
1465
1496
|
}
|
|
1466
1497
|
|
|
1467
1498
|
/** declare-without-git: HEAD does not resolve (no commit) and the plan's witness set records this task's row. */
|
|
@@ -1564,6 +1595,27 @@ export async function rebindStart({ repoRoot, env, planKey, taskId, reason, acto
|
|
|
1564
1595
|
});
|
|
1565
1596
|
}
|
|
1566
1597
|
|
|
1598
|
+
/**
|
|
1599
|
+
* perf-rebind: rebind every carried in-progress task after a revision with the same start event and validator as
|
|
1600
|
+
* `rebindStart`, but one store read and one external-chart read for all of them (the caller has the store and drops the
|
|
1601
|
+
* per-task result, so no per-task store or note-context read). Each event is still its own locked append, so a
|
|
1602
|
+
* refusal names its task. `tasks: [{task_id, actor}]`; calls `onFailure(taskId, error)` and stops at the first refusal.
|
|
1603
|
+
*/
|
|
1604
|
+
export async function rebindCarriedStarts({ repoRoot, env, store, planKey, tasks, reason, onFailure }) {
|
|
1605
|
+
if (tasks.length === 0) return;
|
|
1606
|
+
const validator = externalValidator((await readTodoExternalTasks(store, env)).external_tasks);
|
|
1607
|
+
const writer = createTodoStoreWriter({ caller: 'g5-authoring' });
|
|
1608
|
+
for (const { task_id: taskId, actor } of tasks) {
|
|
1609
|
+
try {
|
|
1610
|
+
await appendTodoEvent({ validateProspectiveEvent: validator, repoRoot, writer, planKey,
|
|
1611
|
+
event: { kind: 'start', task_id: taskId, actor: actor ?? resolveTodoActor(env),
|
|
1612
|
+
payload: { start_mode: 'rebind', reason } } });
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
onFailure(taskId, error);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1567
1619
|
async function retractStart({ repoRoot, env, planKey, taskId, reason }) {
|
|
1568
1620
|
const store = await readTodoStore({ repoRoot });
|
|
1569
1621
|
const binding = resolveTodoStartRetractionBinding(store, { planKey, taskId });
|
|
@@ -1872,9 +1924,11 @@ const samePlanEdge = (member, fromTaskId, toTaskId) => member.plan.hard_dependen
|
|
|
1872
1924
|
* consumer planのplan-scoped chainへ。
|
|
1873
1925
|
*/
|
|
1874
1926
|
async function dependencyConnect(options) {
|
|
1875
|
-
const { repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason } = options;
|
|
1876
|
-
if (fromPlanKey !== toPlanKey) return dependencyConnectLedger(options);
|
|
1927
|
+
const { repoRoot, env, fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason } = options;
|
|
1877
1928
|
const store = await readTodoStore({ repoRoot });
|
|
1929
|
+
// xchart: --from-project omitted or this project = the in-chart routes below, unchanged.
|
|
1930
|
+
if (fromProjectId !== null && fromProjectId !== store.project_id) return dependencyConnectExternal({ ...options, store });
|
|
1931
|
+
if (fromPlanKey !== toPlanKey) return dependencyConnectLedger(options);
|
|
1878
1932
|
const member = store.members.find(({ plan }) => plan.plan_key === fromPlanKey);
|
|
1879
1933
|
const tasks = member?.plan.tasks ?? [];
|
|
1880
1934
|
// 台帳経路と同じ事前検査(plan不在・task不在・自己辺・既存辺・完了済み終点)の拒否を保つ。
|
|
@@ -1897,15 +1951,15 @@ async function dependencyConnect(options) {
|
|
|
1897
1951
|
}
|
|
1898
1952
|
|
|
1899
1953
|
/** A live ledger edge with these endpoints (cross-plan, or an earlier same-plan connect). */
|
|
1900
|
-
function liveLedgerEdge(store, { fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1954
|
+
function liveLedgerEdge(store, { fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1901
1955
|
return projectTodoCrossPlanDependencies(store.members).some((dependency) => (
|
|
1902
|
-
dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1956
|
+
dependency.from.project_id === (fromProjectId ?? store.project_id) && dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1903
1957
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId));
|
|
1904
1958
|
}
|
|
1905
1959
|
|
|
1906
1960
|
/** a28: connect of an existing edge succeeds unchanged, like a repeated done/block/retire (a12). */
|
|
1907
|
-
function dependencyUnchanged(store, { fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1908
|
-
const from = { project_id: store.project_id, plan_key: fromPlanKey, task_id: fromTaskId };
|
|
1961
|
+
function dependencyUnchanged(store, { fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId }) {
|
|
1962
|
+
const from = { project_id: fromProjectId ?? store.project_id, plan_key: fromPlanKey, task_id: fromTaskId };
|
|
1909
1963
|
const to = { project_id: store.project_id, plan_key: toPlanKey, task_id: toTaskId };
|
|
1910
1964
|
const result = {
|
|
1911
1965
|
schema: 'lattice.todo_dependency_unchanged_result.v1', project_id: store.project_id,
|
|
@@ -1954,9 +2008,13 @@ async function dependencyConnectLedger({
|
|
|
1954
2008
|
project_id: store.project_id, plan_key: toPlanKey, task_id: toTaskId,
|
|
1955
2009
|
expected_topology_digest: target.plan.topology_digest,
|
|
1956
2010
|
};
|
|
2011
|
+
return appendLedgerEdge({ repoRoot, env, store, from, to, reason });
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
async function appendLedgerEdge({ repoRoot, env, store, from, to, reason }) {
|
|
1957
2015
|
const { event } = await appendTodoEvent({
|
|
1958
2016
|
validateProspectiveEvent,
|
|
1959
|
-
repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }), planKey:
|
|
2017
|
+
repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }), planKey: to.plan_key,
|
|
1960
2018
|
event: {
|
|
1961
2019
|
kind: 'cross_plan_dependency', actor: resolveTodoActor(env), payload: { from, to, reason },
|
|
1962
2020
|
},
|
|
@@ -1972,9 +2030,54 @@ async function dependencyConnectLedger({
|
|
|
1972
2030
|
return result;
|
|
1973
2031
|
}
|
|
1974
2032
|
|
|
2033
|
+
/**
|
|
2034
|
+
* xchart: wait on a task of another chart. The other chart is read read-only (plan, task, topology, cycle);
|
|
2035
|
+
* the edge is the existing ledger event on this chart's to-plan, nothing is written there.
|
|
2036
|
+
*/
|
|
2037
|
+
async function dependencyConnectExternal({
|
|
2038
|
+
repoRoot, env, store, fromProjectId, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
2039
|
+
}) {
|
|
2040
|
+
const target = store.members.find(({ plan }) => plan.plan_key === toPlanKey);
|
|
2041
|
+
if (target === undefined) {
|
|
2042
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_plan_not_found', undefined, { plan_key: toPlanKey });
|
|
2043
|
+
}
|
|
2044
|
+
if (!target.plan.tasks.some(({ task_id: taskId }) => taskId === toTaskId)) {
|
|
2045
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_task_not_found', undefined, {
|
|
2046
|
+
plan_key: toPlanKey, task_id: toTaskId,
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
const endpoints = { fromProjectId, fromPlanKey, fromTaskId, toPlanKey, toTaskId };
|
|
2050
|
+
if (liveLedgerEdge(store, endpoints)) return dependencyUnchanged(store, endpoints);
|
|
2051
|
+
const other = await readTodoExternalChart(env, fromProjectId);
|
|
2052
|
+
const source = other.members.find(({ plan }) => plan.plan_key === fromPlanKey);
|
|
2053
|
+
if (source === undefined) {
|
|
2054
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_plan_not_found', undefined, {
|
|
2055
|
+
project_id: fromProjectId, plan_key: fromPlanKey,
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
if (!source.plan.tasks.some(({ task_id: taskId }) => taskId === fromTaskId)) {
|
|
2059
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_task_not_found', undefined, {
|
|
2060
|
+
project_id: fromProjectId, plan_key: fromPlanKey, task_id: fromTaskId,
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
const from = { project_id: fromProjectId, plan_key: fromPlanKey, task_id: fromTaskId,
|
|
2064
|
+
expected_topology_digest: source.plan.topology_digest };
|
|
2065
|
+
const to = { project_id: store.project_id, plan_key: toPlanKey, task_id: toTaskId,
|
|
2066
|
+
expected_topology_digest: target.plan.topology_digest };
|
|
2067
|
+
const cycle = await externalCycle({ env, fromStore: other, from, to, localStore: store });
|
|
2068
|
+
if (cycle !== null) {
|
|
2069
|
+
throw new TodoStoreError('DEPENDENCY_CYCLE', 'cross_plan_dependency_cycle', undefined, { from, to, cycle });
|
|
2070
|
+
}
|
|
2071
|
+
return appendLedgerEdge({ repoRoot, env, store, from, to, reason });
|
|
2072
|
+
}
|
|
2073
|
+
|
|
1975
2074
|
// connectの対。同一planでplan本体が持つ辺は軽量改訂で外し(a14)、それ以外は台帳の除去へ。
|
|
1976
2075
|
async function dependencyDisconnect(options) {
|
|
1977
2076
|
const { repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason } = options;
|
|
2077
|
+
// xchart: --from-project equal to this project is the in-chart route.
|
|
2078
|
+
const fromProjectId = options.fromProjectId === null || options.fromProjectId === undefined
|
|
2079
|
+
|| options.fromProjectId === (await readTodoStore({ repoRoot })).project_id ? null : options.fromProjectId;
|
|
2080
|
+
if (fromProjectId !== null) return dependencyDisconnectLedger({ ...options, fromProjectId });
|
|
1978
2081
|
if (fromPlanKey === toPlanKey) {
|
|
1979
2082
|
const store = await readTodoStore({ repoRoot });
|
|
1980
2083
|
const member = store.members.find(({ plan }) => plan.plan_key === fromPlanKey);
|
|
@@ -1989,17 +2092,17 @@ async function dependencyDisconnect(options) {
|
|
|
1989
2092
|
// 誤って張った線の除去(tombstone)。端点で一意に生きた接続を特定し、
|
|
1990
2093
|
// その接続eventが積まれているplanのplan-scoped chainへ除去eventを積む。
|
|
1991
2094
|
async function dependencyDisconnectLedger({
|
|
1992
|
-
repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
2095
|
+
repoRoot, env, fromProjectId = null, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
1993
2096
|
}) {
|
|
1994
2097
|
const store = await readTodoStore({ repoRoot });
|
|
1995
2098
|
const live = projectTodoCrossPlanDependencies(store.members).filter((dependency) => (
|
|
1996
|
-
dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
2099
|
+
dependency.from.project_id === (fromProjectId ?? store.project_id) && dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1997
2100
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId
|
|
1998
2101
|
));
|
|
1999
2102
|
if (live.length === 0) {
|
|
2000
|
-
const from = { plan_key: fromPlanKey, task_id: fromTaskId };
|
|
2103
|
+
const from = { ...(fromProjectId === null ? {} : { project_id: fromProjectId }), plan_key: fromPlanKey, task_id: fromTaskId };
|
|
2001
2104
|
const to = { plan_key: toPlanKey, task_id: toTaskId };
|
|
2002
|
-
if (fromPlanKey === toPlanKey) {
|
|
2105
|
+
if (fromPlanKey === toPlanKey && fromProjectId === null) {
|
|
2003
2106
|
const member = store.members.find(({ plan }) => plan.plan_key === toPlanKey);
|
|
2004
2107
|
const predecessors = (member?.plan.hard_dependencies ?? [])
|
|
2005
2108
|
.filter((edge) => edge.to.task_id === toTaskId).map((edge) => edge.from.task_id).sort();
|
|
@@ -2607,7 +2710,7 @@ async function splitTodo({ repoRoot, env, planKey, inputRef }) {
|
|
|
2607
2710
|
return result;
|
|
2608
2711
|
}
|
|
2609
2712
|
|
|
2610
|
-
async function status({ repoRoot }) {
|
|
2713
|
+
async function status({ repoRoot, env }) {
|
|
2611
2714
|
// No plan yet is an empty project, not a broken store: answer zero plans and how to make one.
|
|
2612
2715
|
if (await isUninitializedTodoStore({ repoRoot })) {
|
|
2613
2716
|
const result = {
|
|
@@ -2619,7 +2722,7 @@ async function status({ repoRoot }) {
|
|
|
2619
2722
|
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
2620
2723
|
return result;
|
|
2621
2724
|
}
|
|
2622
|
-
const store = await
|
|
2725
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
2623
2726
|
const result = projectTodoStatus(store, {
|
|
2624
2727
|
planNotes: await readTodoPlanNotesForStatus({ repoRoot, store }),
|
|
2625
2728
|
parallelCandidates: await readTodoParallelCandidatesForStatus({
|
|
@@ -2650,8 +2753,8 @@ async function adoptDashboardRoot({ repoRoot, env }) {
|
|
|
2650
2753
|
return result;
|
|
2651
2754
|
}
|
|
2652
2755
|
|
|
2653
|
-
async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
2654
|
-
const store = await
|
|
2756
|
+
async function todoDetail({ repoRoot, env, planKey, taskId }) {
|
|
2757
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
2655
2758
|
const [member] = selectMembers(store, planKey);
|
|
2656
2759
|
const task = selectNoteTask(member, taskId);
|
|
2657
2760
|
const state = member.tasks.find(({ task_id: current }) => current === task.task_id);
|
|
@@ -2671,6 +2774,7 @@ async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
|
2671
2774
|
task: { ...task, done_condition: task.done_condition ?? null },
|
|
2672
2775
|
design_memo: designMemoProjection(task),
|
|
2673
2776
|
state,
|
|
2777
|
+
prerequisites: taskPrerequisites(store, member, task.task_id),
|
|
2674
2778
|
note_context: context,
|
|
2675
2779
|
...(featureContext === null ? {} : { feature_context: featureContext }),
|
|
2676
2780
|
result_digest: '',
|
|
@@ -2679,6 +2783,15 @@ async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
|
2679
2783
|
return result;
|
|
2680
2784
|
}
|
|
2681
2785
|
|
|
2786
|
+
/** xchart: what a task waits on, by the readiness predicate (`ready` is the start path's own answer). */
|
|
2787
|
+
function taskPrerequisites(store, member, taskId) {
|
|
2788
|
+
const readiness = createTodoReadiness(store);
|
|
2789
|
+
const key = readiness.key({ ...member.plan, task_id: taskId });
|
|
2790
|
+
const { blocking } = readiness.prerequisites(key);
|
|
2791
|
+
return { ready: readiness.isReady(key), tasks: readiness.prerequisiteRefs(key).tasks,
|
|
2792
|
+
blocking_tasks: blocking.blocking_tasks ?? [], blocking_phases: blocking.blocking_phases ?? [] };
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2682
2795
|
/**
|
|
2683
2796
|
* `taskId === null`はplan単位note。task noteと違い宛先taskが無いので、
|
|
2684
2797
|
* 訂正できる相手はplan noteだけ、返すcontextも特定taskのものにできない。
|
|
@@ -3882,8 +3995,8 @@ function declaredStartHint(store, member, state) {
|
|
|
3882
3995
|
* a40: one task's witness row, declared by its member. Rows nobody declared stay out (an empty row
|
|
3883
3996
|
* would claim "touches nothing"); compile runs once every ready task is declared.
|
|
3884
3997
|
*/
|
|
3885
|
-
async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
3886
|
-
const store = await
|
|
3998
|
+
async function witnessDeclare({ repoRoot, env, planKey, flags }) {
|
|
3999
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
3887
4000
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
3888
4001
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
3889
4002
|
const taskId = flags.task;
|
|
@@ -3910,7 +4023,7 @@ async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
|
3910
4023
|
pointer: at, ...keys, next_action: witnessRoute(planKey) });
|
|
3911
4024
|
}
|
|
3912
4025
|
const scaffolded = await scaffoldWitnessDraft({ repoRoot, planKey, draft });
|
|
3913
|
-
const waitingFor = projectTodoStatus(await
|
|
4026
|
+
const waitingFor = projectTodoStatus(await readTodoStoreForReadiness({ repoRoot, env }), TODO_STATUS_DISPATCH_ONLY).next_ready
|
|
3914
4027
|
.filter((task) => task.plan_key === planKey && !keep.has(task.task_id))
|
|
3915
4028
|
.map(({ task_id: id }) => id).sort();
|
|
3916
4029
|
// declare-without-git: a Store root with no commit cannot be observed, so the row is recorded and not compiled.
|
|
@@ -4408,8 +4521,8 @@ export async function renderTodoGanttForProject({
|
|
|
4408
4521
|
repoRoot, stable = false, displayName = null, env = process.env, readModel = null,
|
|
4409
4522
|
scope = DEFAULT_GANTT_SCOPE, degraded = false,
|
|
4410
4523
|
}) {
|
|
4411
|
-
const store = readModel
|
|
4412
|
-
?? (stable ? await readTodoStoreStable({ repoRoot }) : await readTodoStore({ repoRoot }));
|
|
4524
|
+
const store = await withTodoExternalTasks(readModel
|
|
4525
|
+
?? (stable ? await readTodoStoreStable({ repoRoot }) : await readTodoStore({ repoRoot })), env);
|
|
4413
4526
|
const identity = displayName === null
|
|
4414
4527
|
? await resolveProjectIdentity({ repoRoot, projectId: store.project_id, env })
|
|
4415
4528
|
: { displayName };
|
|
@@ -4696,8 +4809,8 @@ async function blockerList({ repoRoot }) {
|
|
|
4696
4809
|
}
|
|
4697
4810
|
|
|
4698
4811
|
/** Open notices with their waiters (wait-design); an unreadable wait file is named, its waits read as none. */
|
|
4699
|
-
async function openNoticeView(repoRoot) {
|
|
4700
|
-
const store = await
|
|
4812
|
+
async function openNoticeView(repoRoot, env) {
|
|
4813
|
+
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
4701
4814
|
const declared = await declaredWitnessRows(repoRoot, store);
|
|
4702
4815
|
const stored = await readAllTodoNoticeWaits({ repoRoot });
|
|
4703
4816
|
// Readers return raw records: waits that ended since the file's last write are dropped here.
|
|
@@ -4709,8 +4822,8 @@ async function openNoticeView(repoRoot) {
|
|
|
4709
4822
|
return { store, notices, waitUnreadable: stored.unreadable };
|
|
4710
4823
|
}
|
|
4711
4824
|
|
|
4712
|
-
async function openNotices(repoRoot) {
|
|
4713
|
-
return (await openNoticeView(repoRoot)).notices;
|
|
4825
|
+
async function openNotices(repoRoot, env) {
|
|
4826
|
+
return (await openNoticeView(repoRoot, env)).notices;
|
|
4714
4827
|
}
|
|
4715
4828
|
|
|
4716
4829
|
/** lane -> notice_id -> [{waiting_digest, recipients}] from ack set records. */
|
|
@@ -4737,12 +4850,12 @@ function withAckState(notice, index) {
|
|
|
4737
4850
|
const noticeRecipients = (notice) => [...new Set([notice.lane, ...notice.waiting.map(({ agent }) => agent)])].sort();
|
|
4738
4851
|
|
|
4739
4852
|
/** A committed write is never undone for its notices: an unreadable projection says so and `notice list` recovers. */
|
|
4740
|
-
async function withNotices(repoRoot, result, before) {
|
|
4853
|
+
async function withNotices(repoRoot, result, before, env) {
|
|
4741
4854
|
if (result === null || typeof result !== 'object' || typeof result.result_digest !== 'string') return result;
|
|
4742
4855
|
let extra;
|
|
4743
4856
|
try {
|
|
4744
4857
|
if (before === null) throw new Error('notices_before_unreadable');
|
|
4745
|
-
const released = newTodoNotices(before, await openNotices(repoRoot));
|
|
4858
|
+
const released = newTodoNotices(before, await openNotices(repoRoot, env));
|
|
4746
4859
|
// An unreadable ack set only means nobody counts as covered yet: delivery repeats, nothing is lost.
|
|
4747
4860
|
const index = ackIndex(released.length === 0 ? []
|
|
4748
4861
|
: await readAllTodoNoticeAcks({ repoRoot }).then(({ acks }) => acks, () => []));
|
|
@@ -4768,8 +4881,8 @@ function noticeAckRefusal(error, lane) {
|
|
|
4768
4881
|
}
|
|
4769
4882
|
|
|
4770
4883
|
/** `todo notice list`: open notices, unacked unless asked; one unreadable ack file never hides the rest. */
|
|
4771
|
-
async function noticeList({ repoRoot, lane, includeAcked }) {
|
|
4772
|
-
const view = await openNoticeView(repoRoot);
|
|
4884
|
+
async function noticeList({ repoRoot, env, lane, includeAcked }) {
|
|
4885
|
+
const view = await openNoticeView(repoRoot, env);
|
|
4773
4886
|
const open = view.notices.filter((notice) => lane === null || notice.lane === lane);
|
|
4774
4887
|
const records = [];
|
|
4775
4888
|
const ackUnreadable = [];
|
|
@@ -4798,7 +4911,7 @@ async function noticeList({ repoRoot, lane, includeAcked }) {
|
|
|
4798
4911
|
|
|
4799
4912
|
/** `todo notice ack`: an id that is no longer open is reported as closed, never refused (nothing is left to ack). */
|
|
4800
4913
|
async function noticeAck({ repoRoot, env, lane, ids }) {
|
|
4801
|
-
const view = await openNoticeView(repoRoot);
|
|
4914
|
+
const view = await openNoticeView(repoRoot, env);
|
|
4802
4915
|
const laneNotices = view.notices.filter((notice) => notice.lane === lane);
|
|
4803
4916
|
const openIds = laneNotices.map(({ notice_id: id }) => id);
|
|
4804
4917
|
const open = new Set(openIds);
|
|
@@ -4824,7 +4937,7 @@ async function noticeAck({ repoRoot, env, lane, ids }) {
|
|
|
4824
4937
|
* gate: an already startable or finished T is answered with a state and nothing is written.
|
|
4825
4938
|
*/
|
|
4826
4939
|
async function noticeWait({ repoRoot, env, planKey, taskId, reason, cancel }) {
|
|
4827
|
-
const view = await openNoticeView(repoRoot);
|
|
4940
|
+
const view = await openNoticeView(repoRoot, env);
|
|
4828
4941
|
const { store } = view;
|
|
4829
4942
|
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
4830
4943
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
@@ -5196,7 +5309,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5196
5309
|
action = (repoRoot) => repairStoreEol({ repoRoot });
|
|
5197
5310
|
} else if ((argv.length === 1 && argv[0] === 'status')
|
|
5198
5311
|
|| (argv.length === 2 && argv[0] === 'status' && argv[1] === '--json')) {
|
|
5199
|
-
action = (repoRoot) => status({ repoRoot });
|
|
5312
|
+
action = (repoRoot) => status({ repoRoot, env });
|
|
5200
5313
|
} else if (argv.length === 3 && argv[0] === 'dashboard'
|
|
5201
5314
|
&& argv[1] === 'adopt' && argv[2] === '--json') {
|
|
5202
5315
|
action = (repoRoot) => adoptDashboardRoot({ repoRoot, env });
|
|
@@ -5213,7 +5326,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5213
5326
|
};
|
|
5214
5327
|
} else if (argv[0] === 'show' && readFlags(argv, ['show']) !== null) {
|
|
5215
5328
|
const flags = readFlags(argv, ['show']);
|
|
5216
|
-
action = (repoRoot) => todoDetail({ repoRoot, planKey: flags.plan, taskId: flags.task });
|
|
5329
|
+
action = (repoRoot) => todoDetail({ repoRoot, env, planKey: flags.plan, taskId: flags.task });
|
|
5217
5330
|
} else if ((argv.length === 1 && argv[0] === 'bindings')
|
|
5218
5331
|
|| (argv.length === 2 && argv[0] === 'bindings' && argv[1] === '--json')) {
|
|
5219
5332
|
action = (repoRoot) => bindings({ repoRoot, requestedPlanKey: null });
|
|
@@ -5225,7 +5338,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5225
5338
|
&& (argv.length === 2 || (argv.length === 3 && argv[2] === '--json'))) {
|
|
5226
5339
|
// Host display read (BellTeam module): a typed inconsistency is a state, never a refusal.
|
|
5227
5340
|
action = argv[1] === 'read'
|
|
5228
|
-
? async (repoRoot) => (
|
|
5341
|
+
? async (repoRoot) => displayRead(repoRoot, env)
|
|
5229
5342
|
: (repoRoot) => readTodoStoreDisplaySource({ repoRoot });
|
|
5230
5343
|
} else if (argv[0] === 'note' && argv[1] !== 'list') {
|
|
5231
5344
|
const flags = matchFlagCommand(argv, ['note'], NOTE_FLAG_SPEC);
|
|
@@ -5247,7 +5360,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5247
5360
|
&& matchFlagCommand(argv, ['notice', 'list'], TODO_FLAG_SPECS['notice list']) !== null) {
|
|
5248
5361
|
const flags = matchFlagCommand(argv, ['notice', 'list'], TODO_FLAG_SPECS['notice list']);
|
|
5249
5362
|
if (flags.lane === undefined || isNoticeLane(flags.lane)) {
|
|
5250
|
-
action = (repoRoot) => noticeList({ repoRoot, lane: flags.lane ?? null, includeAcked: flags['include-acked'] === true });
|
|
5363
|
+
action = (repoRoot) => noticeList({ repoRoot, env, lane: flags.lane ?? null, includeAcked: flags['include-acked'] === true });
|
|
5251
5364
|
}
|
|
5252
5365
|
} else if (argv[0] === 'notice' && argv[1] === 'ack'
|
|
5253
5366
|
&& matchFlagCommand(argv, ['notice', 'ack'], TODO_FLAG_SPECS['notice ack']) !== null) {
|
|
@@ -5284,14 +5397,14 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5284
5397
|
&& dependencyFlags(argv) !== null) {
|
|
5285
5398
|
const flags = dependencyFlags(argv);
|
|
5286
5399
|
action = (repoRoot) => dependencyConnect({
|
|
5287
|
-
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5400
|
+
repoRoot, env, fromProjectId: flags['from-project'] ?? null, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5288
5401
|
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
5289
5402
|
});
|
|
5290
5403
|
} else if (argv[0] === 'dependency' && argv[1] === 'disconnect'
|
|
5291
5404
|
&& dependencyFlags(argv) !== null) {
|
|
5292
5405
|
const flags = dependencyFlags(argv);
|
|
5293
5406
|
action = (repoRoot) => dependencyDisconnect({
|
|
5294
|
-
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5407
|
+
repoRoot, env, fromProjectId: flags['from-project'] ?? null, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
5295
5408
|
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
5296
5409
|
});
|
|
5297
5410
|
} else if (argv[0] === 'independence' && argv[1] === 'compile') {
|
|
@@ -5362,7 +5475,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5362
5475
|
const flags = matchFlagCommand(argv, ['independence', 'witness', 'declare'],
|
|
5363
5476
|
TODO_FLAG_SPECS['independence witness declare']);
|
|
5364
5477
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
5365
|
-
action = (repoRoot) => witnessDeclare({ repoRoot, planKey: flags.plan, flags });
|
|
5478
|
+
action = (repoRoot) => witnessDeclare({ repoRoot, env, planKey: flags.plan, flags });
|
|
5366
5479
|
}
|
|
5367
5480
|
} else if (argv[0] === 'independence' && argv[1] === 'witness' && argv[2] === 'scaffold') {
|
|
5368
5481
|
const flags = matchFlagCommand(argv, ['independence', 'witness', 'scaffold'],
|
|
@@ -5647,11 +5760,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5647
5760
|
if (writesTodoStore(argv)) {
|
|
5648
5761
|
await ensureActiveProjectDashboard({ repoRoot, env, stderr });
|
|
5649
5762
|
}
|
|
5650
|
-
const before = releasesTasks(argv) ? await openNotices(repoRoot).catch(() => null) : null;
|
|
5763
|
+
const before = releasesTasks(argv) ? await openNotices(repoRoot, env).catch(() => null) : null;
|
|
5651
5764
|
const written = atomicCommit
|
|
5652
5765
|
? await commitTodoStoreMutation({ repoRoot, argv, action, env })
|
|
5653
5766
|
: await action(repoRoot);
|
|
5654
|
-
const result = releasesTasks(argv) ? await withNotices(repoRoot, written, before) : written;
|
|
5767
|
+
const result = releasesTasks(argv) ? await withNotices(repoRoot, written, before, env) : written;
|
|
5655
5768
|
if (result !== null) stdout.write(`${plainVerify ? verifyVerdictLine(result) : JSON.stringify(result)}\n`);
|
|
5656
5769
|
return 0;
|
|
5657
5770
|
} catch (error) {
|
package/src/todo-contracts.mjs
CHANGED
|
@@ -44,6 +44,8 @@ export const TODO_NOTE_EVENT_V2_SCHEMA = 'lattice.todo_note_event.v2';
|
|
|
44
44
|
// Per-lane startable-notice ack set and per-plan waits (host-local; todo-notice-store.mjs).
|
|
45
45
|
export const TODO_NOTICE_ACKS_SCHEMA = 'lattice.todo_notice_acks.v2';
|
|
46
46
|
export const TODO_NOTICE_WAITS_SCHEMA = 'lattice.todo_notice_waits.v1';
|
|
47
|
+
/** a101 K4: chart identity `.lattice/chart.json` (dfd-charts-read). */
|
|
48
|
+
export const TODO_CHART_META_SCHEMA = 'lattice.chart_meta.v1';
|
|
47
49
|
/**
|
|
48
50
|
* v2でnoteの`scope`とplan noteを載せる。v1のままでは`task_id`が identifier 必須・
|
|
49
51
|
* `full_history_command`が`--task <id>`込みの文字列と完全一致で、どちらもplan noteを表せない。
|
|
@@ -846,3 +848,14 @@ export function validateTodoSnapshot(value) {
|
|
|
846
848
|
&& isTodoDigest(value.snapshot_digest) && value.snapshot_digest === todoSelfDigest(value, 'snapshot_digest');
|
|
847
849
|
} catch { return false; }
|
|
848
850
|
}
|
|
851
|
+
|
|
852
|
+
export function validateTodoChartMeta(value) {
|
|
853
|
+
const text = (field) => field === null || (typeof field === 'string' && field.length > 0 && field.length <= 1024);
|
|
854
|
+
const word = (field) => typeof field === 'string' && field.length > 0 && field.length <= 1024;
|
|
855
|
+
const { repo } = value ?? {};
|
|
856
|
+
return exactRecord(value, ['schema', 'name', 'created_by', 'created_at', 'repo'])
|
|
857
|
+
&& value.schema === TODO_CHART_META_SCHEMA && text(value.name) && text(value.created_by)
|
|
858
|
+
&& (value.created_at === null || isStrictTodoTimestamp(value.created_at))
|
|
859
|
+
&& (repo === null || (exactRecord(repo, ['url', 'branch', 'accepted_tip'])
|
|
860
|
+
&& word(repo.url) && word(repo.branch) && text(repo.accepted_tip)));
|
|
861
|
+
}
|