@quolu/lattice 0.34.2 → 0.36.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/README.ja.md +54 -4
- package/README.md +8 -0
- package/bin/lattice.mjs +15 -3
- package/docs/bridge-setup.md +13 -0
- package/package.json +1 -1
- package/src/cli-help.mjs +20 -9
- package/src/project-cli.mjs +126 -3
- package/src/todo-cli.mjs +224 -22
- package/src/todo-contracts.mjs +2 -2
- package/src/todo-dispatch-shape.mjs +190 -0
- package/src/todo-gantt-html-shared.mjs +2 -1
- package/src/todo-gantt-layout.mjs +13 -3
- package/src/todo-gantt-live.mjs +21 -2
- package/src/todo-gantt-scope.mjs +27 -2
- package/src/todo-migration.mjs +108 -0
- package/src/todo-revision.mjs +568 -2
- package/src/todo-status.mjs +5 -2
- package/src/todo-store.mjs +155 -33
package/src/todo-revision.mjs
CHANGED
|
@@ -185,7 +185,7 @@ function validTaskMigration(value) {
|
|
|
185
185
|
]) && isTodoIdentifier(entry.from_task_id)
|
|
186
186
|
&& (entry.to_task_id === 'removed' || isTodoIdentifier(entry.to_task_id))
|
|
187
187
|
&& ((entry.state_policy === 'removed' && entry.to_task_id === 'removed')
|
|
188
|
-
|| (['carry', 'carry_reconciled_metadata', 'reset_pending'].includes(entry.state_policy)
|
|
188
|
+
|| (['carry', 'carry_reconciled_metadata', 'reset_pending', 'acquire_phase'].includes(entry.state_policy)
|
|
189
189
|
&& entry.to_task_id !== 'removed')))
|
|
190
190
|
&& new Set(value.map(({ from_task_id }) => from_task_id)).size === value.length
|
|
191
191
|
&& new Set(activeTargets).size === activeTargets.length
|
|
@@ -277,8 +277,11 @@ function validRuntimeTodoProjection(runtimeMigration, taskMigration) {
|
|
|
277
277
|
return projected.length === taskMigration.length && projected.every((expected, index) => {
|
|
278
278
|
const actual = taskMigration[index];
|
|
279
279
|
return expected.from_task_id === actual.from_task_id && expected.to_task_id === actual.to_task_id
|
|
280
|
+
// runtime disposition carry/stayは実行状態の持ち越しだけを申告する。task_migration側は
|
|
281
|
+
// carry_reconciled_metadataに加え、Phase獲得だけを許すacquire_phase(ADR 0147裁定4)も
|
|
282
|
+
// 「状態を持ち越すcarry系」の投影として受理する。
|
|
280
283
|
&& (expected.state_policy === 'carry'
|
|
281
|
-
? ['carry', 'carry_reconciled_metadata'].includes(actual.state_policy)
|
|
284
|
+
? ['carry', 'carry_reconciled_metadata', 'acquire_phase'].includes(actual.state_policy)
|
|
282
285
|
: expected.state_policy === actual.state_policy);
|
|
283
286
|
});
|
|
284
287
|
}
|
|
@@ -396,6 +399,569 @@ export function validateTodoRevision(value) {
|
|
|
396
399
|
} catch { return false; }
|
|
397
400
|
}
|
|
398
401
|
|
|
402
|
+
const reject = (reason, path = '') => ({ valid: false, reason, path });
|
|
403
|
+
|
|
404
|
+
function plainObject(value) {
|
|
405
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* 期待keyとの過不足を1件ずつ言い当てる。missing/unexpectedのどちらが先に見つかっても
|
|
410
|
+
* そこで止め、複数の欠落を一度に説明しない——`exactRecord`のbooleanと違い、
|
|
411
|
+
* 最初に見つかった違反fieldをpathへ刻む(ADR 0130の案内規律をrevision入口へ拡張)。
|
|
412
|
+
*/
|
|
413
|
+
function explainKeys(value, requiredKeys, at) {
|
|
414
|
+
if (!plainObject(value) || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
415
|
+
return reject('not_an_object', at);
|
|
416
|
+
}
|
|
417
|
+
const actualKeys = new Set(Object.keys(value));
|
|
418
|
+
for (const key of requiredKeys) {
|
|
419
|
+
if (!actualKeys.has(key)) return reject('missing_required_key', `${at}/${key}`);
|
|
420
|
+
}
|
|
421
|
+
const requiredSet = new Set(requiredKeys);
|
|
422
|
+
for (const key of actualKeys) {
|
|
423
|
+
if (!requiredSet.has(key)) return reject('unexpected_key', `${at}/${key}`);
|
|
424
|
+
}
|
|
425
|
+
return { valid: true };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function explainPredecessor(value, at = '/predecessor') {
|
|
429
|
+
const keyCheck = explainKeys(value, ['plan_digest', 'journal_head_digest', 'plan_version'], at);
|
|
430
|
+
if (!keyCheck.valid) return keyCheck;
|
|
431
|
+
if (!isTodoDigest(value.plan_digest)) return reject('invalid_digest', `${at}/plan_digest`);
|
|
432
|
+
if (!isTodoDigest(value.journal_head_digest)) return reject('invalid_digest', `${at}/journal_head_digest`);
|
|
433
|
+
if (!isTodoIdentifier(value.plan_version)) return reject('invalid_identifier', `${at}/plan_version`);
|
|
434
|
+
return { valid: true };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* 実運用で最も時間を溶かした違反——配列のソート漏れ——を、壊れているindexを名指しして返す。
|
|
439
|
+
* `validTaskMigration`と同じ規則(from_task_idの厳密昇順、from/toの重複禁止)を、
|
|
440
|
+
* 可否を変えずに1件ずつ言い当てる。
|
|
441
|
+
*/
|
|
442
|
+
function explainTaskMigration(value, at = '/task_migration') {
|
|
443
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 512) {
|
|
444
|
+
return reject('bounded_collection_violation', at);
|
|
445
|
+
}
|
|
446
|
+
for (const [index, entry] of value.entries()) {
|
|
447
|
+
const entryAt = `${at}/${index}`;
|
|
448
|
+
const keyCheck = explainKeys(entry, ['from_task_id', 'to_task_id', 'state_policy'], entryAt);
|
|
449
|
+
if (!keyCheck.valid) return keyCheck;
|
|
450
|
+
if (!isTodoIdentifier(entry.from_task_id)) return reject('invalid_identifier', `${entryAt}/from_task_id`);
|
|
451
|
+
if (entry.to_task_id !== 'removed' && !isTodoIdentifier(entry.to_task_id)) {
|
|
452
|
+
return reject('invalid_identifier', `${entryAt}/to_task_id`);
|
|
453
|
+
}
|
|
454
|
+
const validPolicy = (entry.state_policy === 'removed' && entry.to_task_id === 'removed')
|
|
455
|
+
|| (['carry', 'carry_reconciled_metadata', 'reset_pending', 'acquire_phase'].includes(entry.state_policy)
|
|
456
|
+
&& entry.to_task_id !== 'removed');
|
|
457
|
+
if (!validPolicy) return reject('state_policy_disposition_mismatch', `${entryAt}/state_policy`);
|
|
458
|
+
}
|
|
459
|
+
if (new Set(value.map(({ from_task_id: fromTaskId }) => fromTaskId)).size !== value.length) {
|
|
460
|
+
return reject('duplicate_from_task_id', at);
|
|
461
|
+
}
|
|
462
|
+
const activeTargets = value.filter(({ to_task_id: toTaskId }) => toTaskId !== 'removed')
|
|
463
|
+
.map(({ to_task_id: toTaskId }) => toTaskId);
|
|
464
|
+
if (new Set(activeTargets).size !== activeTargets.length) {
|
|
465
|
+
return reject('duplicate_to_task_id', at);
|
|
466
|
+
}
|
|
467
|
+
for (let index = 1; index < value.length; index += 1) {
|
|
468
|
+
if (compareText(value[index - 1].from_task_id, value[index].from_task_id) >= 0) {
|
|
469
|
+
return reject('unsorted_or_duplicate_collection', `${at}/${index}/from_task_id`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return { valid: true };
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function explainPhaseMigration(value, desiredPlan, at = '/phase_migration') {
|
|
476
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 512) {
|
|
477
|
+
return reject('bounded_collection_violation', at);
|
|
478
|
+
}
|
|
479
|
+
for (const [index, entry] of value.entries()) {
|
|
480
|
+
const entryAt = `${at}/${index}`;
|
|
481
|
+
const keyCheck = explainKeys(entry, ['from_phase_id', 'to_phase_id', 'state_policy'], entryAt);
|
|
482
|
+
if (!keyCheck.valid) return keyCheck;
|
|
483
|
+
if (entry.from_phase_id !== null && !isTodoIdentifier(entry.from_phase_id)) {
|
|
484
|
+
return reject('invalid_identifier', `${entryAt}/from_phase_id`);
|
|
485
|
+
}
|
|
486
|
+
if (entry.to_phase_id !== 'removed' && !isTodoIdentifier(entry.to_phase_id)) {
|
|
487
|
+
return reject('invalid_identifier', `${entryAt}/to_phase_id`);
|
|
488
|
+
}
|
|
489
|
+
if (!['carry', 'reset', 'removed'].includes(entry.state_policy)) {
|
|
490
|
+
return reject('invalid_state_policy', `${entryAt}/state_policy`);
|
|
491
|
+
}
|
|
492
|
+
if (entry.state_policy === 'carry'
|
|
493
|
+
&& (entry.from_phase_id === null || entry.to_phase_id === 'removed')) {
|
|
494
|
+
return reject('state_policy_disposition_mismatch', entryAt);
|
|
495
|
+
}
|
|
496
|
+
if (entry.state_policy === 'removed'
|
|
497
|
+
&& (entry.from_phase_id === null || entry.to_phase_id !== 'removed')) {
|
|
498
|
+
return reject('state_policy_disposition_mismatch', entryAt);
|
|
499
|
+
}
|
|
500
|
+
if (entry.state_policy === 'reset' && entry.to_phase_id === 'removed') {
|
|
501
|
+
return reject('state_policy_disposition_mismatch', entryAt);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const sources = value.filter(({ from_phase_id: fromPhaseId }) => fromPhaseId !== null)
|
|
505
|
+
.map(({ from_phase_id: fromPhaseId }) => fromPhaseId);
|
|
506
|
+
if (new Set(sources).size !== sources.length) return reject('duplicate_from_phase_id', at);
|
|
507
|
+
const targets = value.filter(({ to_phase_id: toPhaseId }) => toPhaseId !== 'removed')
|
|
508
|
+
.map(({ to_phase_id: toPhaseId }) => toPhaseId);
|
|
509
|
+
if (new Set(targets).size !== targets.length) return reject('duplicate_to_phase_id', at);
|
|
510
|
+
if (canonicalizeForCompare(targets)
|
|
511
|
+
!== canonicalizeForCompare(desiredPlan.phases.map(({ phase_id: phaseId }) => phaseId))) {
|
|
512
|
+
return reject('phase_migration_target_set_mismatch', at);
|
|
513
|
+
}
|
|
514
|
+
return { valid: true };
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function explainRuntimeTaskMigration(value, taskMigration, desiredPlan, at = '/runtime_task_migration') {
|
|
518
|
+
const keyCheck = explainKeys(value, ['schema', 'entries', 'migration_digest'], at);
|
|
519
|
+
if (!keyCheck.valid) return keyCheck;
|
|
520
|
+
if (value.schema !== 'lattice.runtime_task_migration.v1') return reject('schema_mismatch', `${at}/schema`);
|
|
521
|
+
if (!Array.isArray(value.entries) || value.entries.length === 0 || value.entries.length > 512) {
|
|
522
|
+
return reject('bounded_collection_violation', `${at}/entries`);
|
|
523
|
+
}
|
|
524
|
+
const targets = [];
|
|
525
|
+
for (const [index, entry] of value.entries.entries()) {
|
|
526
|
+
const entryAt = `${at}/entries/${index}`;
|
|
527
|
+
const keys = ['predecessor_task_id', 'disposition', 'successor_task_ids', 'reason', 'evidence_digests'];
|
|
528
|
+
const entryKeyCheck = explainKeys(entry, keys, entryAt);
|
|
529
|
+
if (!entryKeyCheck.valid) return entryKeyCheck;
|
|
530
|
+
if (!isTodoIdentifier(entry.predecessor_task_id)) {
|
|
531
|
+
return reject('invalid_identifier', `${entryAt}/predecessor_task_id`);
|
|
532
|
+
}
|
|
533
|
+
if (!['carry', 'stay', 'replace', 'split', 'retire'].includes(entry.disposition)) {
|
|
534
|
+
return reject('invalid_disposition', `${entryAt}/disposition`);
|
|
535
|
+
}
|
|
536
|
+
if (!Array.isArray(entry.successor_task_ids) || entry.successor_task_ids.length > 512
|
|
537
|
+
|| !entry.successor_task_ids.every(isTodoIdentifier)) {
|
|
538
|
+
return reject('invalid_successor_task_ids', `${entryAt}/successor_task_ids`);
|
|
539
|
+
}
|
|
540
|
+
if (new Set(entry.successor_task_ids).size !== entry.successor_task_ids.length) {
|
|
541
|
+
return reject('duplicate_successor_task_id', `${entryAt}/successor_task_ids`);
|
|
542
|
+
}
|
|
543
|
+
const successorTail = entry.successor_task_ids.slice(1);
|
|
544
|
+
for (let tailIndex = 1; tailIndex < successorTail.length; tailIndex += 1) {
|
|
545
|
+
if (compareText(successorTail[tailIndex - 1], successorTail[tailIndex]) >= 0) {
|
|
546
|
+
return reject('unsorted_or_duplicate_collection', `${entryAt}/successor_task_ids/${tailIndex + 1}`);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (!boundedText(entry.reason)) return reject('invalid_text', `${entryAt}/reason`);
|
|
550
|
+
if (!Array.isArray(entry.evidence_digests) || entry.evidence_digests.length === 0
|
|
551
|
+
|| entry.evidence_digests.length > 512 || !entry.evidence_digests.every(isTodoDigest)) {
|
|
552
|
+
return reject('invalid_evidence_digests', `${entryAt}/evidence_digests`);
|
|
553
|
+
}
|
|
554
|
+
if (new Set(entry.evidence_digests).size !== entry.evidence_digests.length) {
|
|
555
|
+
return reject('duplicate_evidence_digest', `${entryAt}/evidence_digests`);
|
|
556
|
+
}
|
|
557
|
+
for (let digestIndex = 1; digestIndex < entry.evidence_digests.length; digestIndex += 1) {
|
|
558
|
+
if (compareText(entry.evidence_digests[digestIndex - 1], entry.evidence_digests[digestIndex]) >= 0) {
|
|
559
|
+
return reject('unsorted_or_duplicate_collection', `${entryAt}/evidence_digests/${digestIndex}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (['carry', 'stay'].includes(entry.disposition)
|
|
563
|
+
&& (entry.successor_task_ids.length !== 1
|
|
564
|
+
|| entry.successor_task_ids[0] !== entry.predecessor_task_id)) {
|
|
565
|
+
return reject('disposition_successor_mismatch', entryAt);
|
|
566
|
+
}
|
|
567
|
+
if (entry.disposition === 'retire' && entry.successor_task_ids.length !== 0) {
|
|
568
|
+
return reject('disposition_successor_mismatch', entryAt);
|
|
569
|
+
}
|
|
570
|
+
if (['replace', 'split'].includes(entry.disposition) && entry.successor_task_ids.length === 0) {
|
|
571
|
+
return reject('disposition_successor_mismatch', entryAt);
|
|
572
|
+
}
|
|
573
|
+
if (index > 0 && compareText(value.entries[index - 1].predecessor_task_id,
|
|
574
|
+
entry.predecessor_task_id) >= 0) {
|
|
575
|
+
return reject('unsorted_or_duplicate_collection', `${at}/entries/${index}/predecessor_task_id`);
|
|
576
|
+
}
|
|
577
|
+
targets.push(...entry.successor_task_ids);
|
|
578
|
+
}
|
|
579
|
+
if (new Set(targets).size !== targets.length) return reject('duplicate_successor_task_id_across_entries', `${at}/entries`);
|
|
580
|
+
if (!isTodoDigest(value.migration_digest)) return reject('invalid_digest', `${at}/migration_digest`);
|
|
581
|
+
const expectedMigrationDigest = todoSelfDigest(value, 'migration_digest');
|
|
582
|
+
if (value.migration_digest !== expectedMigrationDigest) {
|
|
583
|
+
return reject('migration_digest_mismatch', `${at}/migration_digest`);
|
|
584
|
+
}
|
|
585
|
+
if (!validRuntimeTodoProjection(value, taskMigration)) {
|
|
586
|
+
return reject('runtime_task_migration_projection_mismatch', at);
|
|
587
|
+
}
|
|
588
|
+
if (canonicalizeForCompare(value.entries.flatMap(({ successor_task_ids: ids }) => ids))
|
|
589
|
+
!== canonicalizeForCompare(desiredPlan.tasks.map(({ task_id: taskId }) => taskId))) {
|
|
590
|
+
return reject('runtime_task_migration_target_set_mismatch', at);
|
|
591
|
+
}
|
|
592
|
+
return { valid: true };
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function explainSourceInventory(value, desiredPlan, { requireNarrativeRef = false } = {}, at = '/source_inventory') {
|
|
596
|
+
const keyCheck = explainKeys(value, ['active', 'excluded_tombstones'], at);
|
|
597
|
+
if (!keyCheck.valid) return keyCheck;
|
|
598
|
+
if (!Array.isArray(value.active) || value.active.length > 512) {
|
|
599
|
+
return reject('bounded_collection_violation', `${at}/active`);
|
|
600
|
+
}
|
|
601
|
+
if (!Array.isArray(value.excluded_tombstones) || value.excluded_tombstones.length > 2_048) {
|
|
602
|
+
return reject('bounded_collection_violation', `${at}/excluded_tombstones`);
|
|
603
|
+
}
|
|
604
|
+
for (const [index, entry] of value.active.entries()) {
|
|
605
|
+
const entryAt = `${at}/active/${index}`;
|
|
606
|
+
const entryKeyCheck = explainKeys(entry, ['task_id', 'source_ref', 'source_digest'], entryAt);
|
|
607
|
+
if (!entryKeyCheck.valid) return entryKeyCheck;
|
|
608
|
+
if (!isTodoIdentifier(entry.task_id)) return reject('invalid_identifier', `${entryAt}/task_id`);
|
|
609
|
+
if (parseTodoSourceRef(entry.source_ref) === null) return reject('invalid_source_ref', `${entryAt}/source_ref`);
|
|
610
|
+
if (!isTodoDigest(entry.source_digest)) return reject('invalid_digest', `${entryAt}/source_digest`);
|
|
611
|
+
}
|
|
612
|
+
for (const [index, entry] of value.excluded_tombstones.entries()) {
|
|
613
|
+
const entryAt = `${at}/excluded_tombstones/${index}`;
|
|
614
|
+
const entryKeyCheck = explainKeys(entry, ['source_ref', 'source_digest', 'exclusion_reason'], entryAt);
|
|
615
|
+
if (!entryKeyCheck.valid) return entryKeyCheck;
|
|
616
|
+
if (parseTodoSourceRef(entry.source_ref) === null) return reject('invalid_source_ref', `${entryAt}/source_ref`);
|
|
617
|
+
if (!isTodoDigest(entry.source_digest)) return reject('invalid_digest', `${entryAt}/source_digest`);
|
|
618
|
+
if (!boundedText(entry.exclusion_reason)) return reject('invalid_text', `${entryAt}/exclusion_reason`);
|
|
619
|
+
}
|
|
620
|
+
const taskIds = desiredPlan.tasks.map(({ task_id: taskId }) => taskId);
|
|
621
|
+
const activeIds = value.active.map(({ task_id: taskId }) => taskId);
|
|
622
|
+
if (taskIds.length !== activeIds.length || !taskIds.every((id, index) => id === activeIds[index])) {
|
|
623
|
+
return reject('source_inventory_task_set_mismatch', `${at}/active`);
|
|
624
|
+
}
|
|
625
|
+
if (requireNarrativeRef) {
|
|
626
|
+
for (const [index, entry] of value.active.entries()) {
|
|
627
|
+
const task = desiredPlan.tasks.find(({ task_id: taskId }) => taskId === entry.task_id);
|
|
628
|
+
if (task?.narrative_ref !== entry.source_ref) {
|
|
629
|
+
return reject('source_inventory_narrative_ref_mismatch', `${at}/active/${index}/source_ref`);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
const activeRefs = value.active.map(({ source_ref: sourceRef }) => sourceRef);
|
|
634
|
+
if (new Set(activeRefs).size !== activeRefs.length) return reject('duplicate_source_ref', `${at}/active`);
|
|
635
|
+
const tombstoneRefs = value.excluded_tombstones.map(({ source_ref: sourceRef }) => sourceRef);
|
|
636
|
+
if (new Set(tombstoneRefs).size !== tombstoneRefs.length) {
|
|
637
|
+
return reject('duplicate_source_ref', `${at}/excluded_tombstones`);
|
|
638
|
+
}
|
|
639
|
+
const activeRefSet = new Set(activeRefs);
|
|
640
|
+
if (tombstoneRefs.some((ref) => activeRefSet.has(ref))) {
|
|
641
|
+
return reject('tombstone_ref_still_active', `${at}/excluded_tombstones`);
|
|
642
|
+
}
|
|
643
|
+
for (let index = 1; index < value.excluded_tombstones.length; index += 1) {
|
|
644
|
+
if (compareText(value.excluded_tombstones[index - 1].source_ref,
|
|
645
|
+
value.excluded_tombstones[index].source_ref) >= 0) {
|
|
646
|
+
return reject('unsorted_or_duplicate_collection', `${at}/excluded_tombstones/${index}/source_ref`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return { valid: true };
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function explainSourceCutoverBatch(value, revision, at = '/source_cutover_batch') {
|
|
653
|
+
const keyCheck = explainKeys(value, ['batch_id', 'archive_ref', 'operations', 'batch_digest'], at);
|
|
654
|
+
if (!keyCheck.valid) return keyCheck;
|
|
655
|
+
if (!isTodoIdentifier(value.batch_id)) return reject('invalid_identifier', `${at}/batch_id`);
|
|
656
|
+
if (!isTodoRef(value.archive_ref) || !value.archive_ref.endsWith('.md')
|
|
657
|
+
|| parseTodoSourceRef(value.archive_ref) !== null) {
|
|
658
|
+
return reject('invalid_archive_ref', `${at}/archive_ref`);
|
|
659
|
+
}
|
|
660
|
+
if (!Array.isArray(value.operations) || value.operations.length === 0 || value.operations.length > 512) {
|
|
661
|
+
return reject('bounded_collection_violation', `${at}/operations`);
|
|
662
|
+
}
|
|
663
|
+
const sourceRefs = new Set();
|
|
664
|
+
const activeTaskIds = new Set();
|
|
665
|
+
for (const [index, operation] of value.operations.entries()) {
|
|
666
|
+
const opAt = `${at}/operations/${index}`;
|
|
667
|
+
const keys = ['task_id', 'disposition', 'source_ref', 'source_digest', 'live_replacement'];
|
|
668
|
+
const opKeyCheck = explainKeys(operation, keys, opAt);
|
|
669
|
+
if (!opKeyCheck.valid) return opKeyCheck;
|
|
670
|
+
if (!['active', 'excluded'].includes(operation.disposition)) {
|
|
671
|
+
return reject('invalid_disposition', `${opAt}/disposition`);
|
|
672
|
+
}
|
|
673
|
+
if (operation.disposition === 'active' ? !isTodoIdentifier(operation.task_id)
|
|
674
|
+
: operation.task_id !== null) {
|
|
675
|
+
return reject('task_id_disposition_mismatch', `${opAt}/task_id`);
|
|
676
|
+
}
|
|
677
|
+
if (parseTodoSourceRef(operation.source_ref) === null) return reject('invalid_source_ref', `${opAt}/source_ref`);
|
|
678
|
+
if (!isTodoDigest(operation.source_digest)) return reject('invalid_digest', `${opAt}/source_digest`);
|
|
679
|
+
if (!validLiveReplacement(operation.live_replacement)) {
|
|
680
|
+
return reject('invalid_live_replacement', `${opAt}/live_replacement`);
|
|
681
|
+
}
|
|
682
|
+
if (sourceRefs.has(operation.source_ref)) return reject('duplicate_source_ref', `${opAt}/source_ref`);
|
|
683
|
+
sourceRefs.add(operation.source_ref);
|
|
684
|
+
if (index > 0 && compareText(value.operations[index - 1].source_ref, operation.source_ref) >= 0) {
|
|
685
|
+
return reject('unsorted_or_duplicate_collection', `${opAt}/source_ref`);
|
|
686
|
+
}
|
|
687
|
+
const archivedSourceRef = todoCutoverArchiveSourceRef(value, index);
|
|
688
|
+
if (operation.disposition === 'active') {
|
|
689
|
+
if (activeTaskIds.has(operation.task_id)) return reject('duplicate_task_id', `${opAt}/task_id`);
|
|
690
|
+
activeTaskIds.add(operation.task_id);
|
|
691
|
+
const inventory = revision.source_inventory.active
|
|
692
|
+
.find(({ task_id: taskId }) => taskId === operation.task_id);
|
|
693
|
+
const task = revision.desired_plan.tasks.find(({ task_id: taskId }) => taskId === operation.task_id);
|
|
694
|
+
if (inventory?.source_ref !== archivedSourceRef || inventory.source_digest !== operation.source_digest
|
|
695
|
+
|| task?.narrative_ref !== archivedSourceRef) {
|
|
696
|
+
return reject('cutover_operation_not_bound_to_inventory', opAt);
|
|
697
|
+
}
|
|
698
|
+
} else {
|
|
699
|
+
const tombstone = revision.source_inventory.excluded_tombstones.find((entry) => (
|
|
700
|
+
entry.source_ref === archivedSourceRef && entry.source_digest === operation.source_digest
|
|
701
|
+
));
|
|
702
|
+
if (tombstone === undefined) return reject('cutover_operation_not_bound_to_tombstone', opAt);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (!isTodoDigest(value.batch_digest)) return reject('invalid_digest', `${at}/batch_digest`);
|
|
706
|
+
const expectedBatchDigest = todoSelfDigest(value, 'batch_digest');
|
|
707
|
+
if (value.batch_digest !== expectedBatchDigest) return reject('batch_digest_mismatch', `${at}/batch_digest`);
|
|
708
|
+
return { valid: true };
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* `lattice todo revise`が受理する`lattice.todo_revision.v1/v2`を診断する。
|
|
713
|
+
*
|
|
714
|
+
* `validateTodoRevision`の可否は変えない。desired_plan自体のgraph整合
|
|
715
|
+
* (task/phase閉包・topology digest)は`validateTodoPlan`任せの単一reasonへ丸め、
|
|
716
|
+
* ここでは実運用で詰まった箇所——必須key・task_migrationのソート・各digestの不一致——
|
|
717
|
+
* を優先して名指しする。
|
|
718
|
+
*/
|
|
719
|
+
export function explainTodoRevision(value) {
|
|
720
|
+
try {
|
|
721
|
+
if (!plainObject(value)) return reject('not_an_object', '');
|
|
722
|
+
const revisionV1 = value.schema === 'lattice.todo_revision.v1';
|
|
723
|
+
const revisionV2 = value.schema === 'lattice.todo_revision.v2';
|
|
724
|
+
if (!revisionV1 && !revisionV2) return reject('schema_mismatch', '/schema');
|
|
725
|
+
const keyCheck = explainKeys(value, revisionV1 ? REVISION_V1_KEYS : REVISION_V2_KEYS, '');
|
|
726
|
+
if (!keyCheck.valid) return keyCheck;
|
|
727
|
+
if (!isTodoIdentifier(value.project_id)) return reject('invalid_identifier', '/project_id');
|
|
728
|
+
if (!isTodoIdentifier(value.plan_key)) return reject('invalid_identifier', '/plan_key');
|
|
729
|
+
const predecessorCheck = explainPredecessor(value.predecessor);
|
|
730
|
+
if (!predecessorCheck.valid) return predecessorCheck;
|
|
731
|
+
if (!validateTodoPlan(value.desired_plan)) return reject('desired_plan_invalid', '/desired_plan');
|
|
732
|
+
if (value.desired_plan.schema !== 'lattice.todo_plan.v3') {
|
|
733
|
+
return reject('desired_plan_schema_mismatch', '/desired_plan/schema');
|
|
734
|
+
}
|
|
735
|
+
if (value.desired_plan.project_id !== value.project_id) {
|
|
736
|
+
return reject('desired_plan_project_id_mismatch', '/desired_plan/project_id');
|
|
737
|
+
}
|
|
738
|
+
if (value.desired_plan.plan_key !== value.plan_key) {
|
|
739
|
+
return reject('desired_plan_plan_key_mismatch', '/desired_plan/plan_key');
|
|
740
|
+
}
|
|
741
|
+
if (value.desired_plan.predecessor_plan_digest !== value.predecessor.plan_digest) {
|
|
742
|
+
return reject('desired_plan_predecessor_mismatch', '/desired_plan/predecessor_plan_digest');
|
|
743
|
+
}
|
|
744
|
+
const taskMigrationCheck = explainTaskMigration(value.task_migration);
|
|
745
|
+
if (!taskMigrationCheck.valid) return taskMigrationCheck;
|
|
746
|
+
const sourceCutoverBatch = revisionV2 ? value.source_cutover_batch : undefined;
|
|
747
|
+
const sourceInventoryCheck = explainSourceInventory(value.source_inventory, value.desired_plan);
|
|
748
|
+
if (!sourceInventoryCheck.valid) return sourceInventoryCheck;
|
|
749
|
+
const expectedPlanVersion = todoRevisionPlanVersion({
|
|
750
|
+
projectId: value.project_id, planKey: value.plan_key, predecessor: value.predecessor,
|
|
751
|
+
desiredPlan: value.desired_plan, taskMigration: value.task_migration,
|
|
752
|
+
sourceInventory: value.source_inventory, sourceCutoverBatch,
|
|
753
|
+
});
|
|
754
|
+
if (value.desired_plan.plan_version !== expectedPlanVersion) {
|
|
755
|
+
return reject('plan_version_mismatch', '/desired_plan/plan_version');
|
|
756
|
+
}
|
|
757
|
+
const reconciliationCheck = explainKeys(value.reconciliation, [
|
|
758
|
+
'predecessor_reconciliation_digest', 'source_inventory_digest', 'reconciliation_digest',
|
|
759
|
+
], '/reconciliation');
|
|
760
|
+
if (!reconciliationCheck.valid) return reconciliationCheck;
|
|
761
|
+
if (!isTodoDigest(value.reconciliation.predecessor_reconciliation_digest)) {
|
|
762
|
+
return reject('invalid_digest', '/reconciliation/predecessor_reconciliation_digest');
|
|
763
|
+
}
|
|
764
|
+
const expectedSourceInventoryDigest = todoSourceInventoryDigest(value.source_inventory);
|
|
765
|
+
if (value.reconciliation.source_inventory_digest !== expectedSourceInventoryDigest) {
|
|
766
|
+
return reject('source_inventory_digest_mismatch', '/reconciliation/source_inventory_digest');
|
|
767
|
+
}
|
|
768
|
+
const expectedReconciliationDigest = todoReconciliationDigest({
|
|
769
|
+
predecessorReconciliationDigest: value.reconciliation.predecessor_reconciliation_digest,
|
|
770
|
+
sourceInventoryDigest: value.reconciliation.source_inventory_digest,
|
|
771
|
+
predecessor: value.predecessor, desiredPlanDigest: value.desired_plan.plan_digest,
|
|
772
|
+
taskMigration: value.task_migration, sourceCutoverBatch,
|
|
773
|
+
});
|
|
774
|
+
if (value.reconciliation.reconciliation_digest !== expectedReconciliationDigest) {
|
|
775
|
+
return reject('reconciliation_digest_mismatch', '/reconciliation/reconciliation_digest');
|
|
776
|
+
}
|
|
777
|
+
if (revisionV2) {
|
|
778
|
+
const cutoverCheck = explainSourceCutoverBatch(value.source_cutover_batch, value);
|
|
779
|
+
if (!cutoverCheck.valid) return cutoverCheck;
|
|
780
|
+
}
|
|
781
|
+
const targets = new Set(value.desired_plan.tasks.map(({ task_id: taskId }) => taskId));
|
|
782
|
+
const badTargetIndex = value.task_migration
|
|
783
|
+
.findIndex(({ to_task_id: toTaskId }) => toTaskId !== 'removed' && !targets.has(toTaskId));
|
|
784
|
+
if (badTargetIndex !== -1) {
|
|
785
|
+
return reject('task_migration_target_unresolved', `/task_migration/${badTargetIndex}/to_task_id`);
|
|
786
|
+
}
|
|
787
|
+
if (!isTodoDigest(value.revision_digest)) return reject('invalid_digest', '/revision_digest');
|
|
788
|
+
const expectedRevisionDigest = todoSelfDigest(value, 'revision_digest');
|
|
789
|
+
if (value.revision_digest !== expectedRevisionDigest) {
|
|
790
|
+
return reject('revision_digest_mismatch', '/revision_digest');
|
|
791
|
+
}
|
|
792
|
+
// ここまでの個別検査を全て通過したのに`validateTodoRevision`がfalseを返す状況は、
|
|
793
|
+
// このexplainがまだ言い当てられない違反があるということ。捏造せず未特定と申告する。
|
|
794
|
+
return { valid: true };
|
|
795
|
+
} catch {
|
|
796
|
+
return reject('diagnosis_failed', '');
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* `lattice todo revise-phase`が受理する`lattice.phase_todo_revision.v1/v2/v3`を診断する。
|
|
802
|
+
* 方針は`explainTodoRevision`と同じ——desired_planのgraph整合は単一reasonへ丸め、
|
|
803
|
+
* v3で増える`runtime_task_migration`・`source_cutover_batch`・8-key reconciliationの
|
|
804
|
+
* 各digestを個別に名指しする。
|
|
805
|
+
*/
|
|
806
|
+
export function explainPhaseTodoRevision(value) {
|
|
807
|
+
try {
|
|
808
|
+
if (!plainObject(value)) return reject('not_an_object', '');
|
|
809
|
+
const revisionV1 = value.schema === 'lattice.phase_todo_revision.v1';
|
|
810
|
+
const revisionV2 = value.schema === 'lattice.phase_todo_revision.v2';
|
|
811
|
+
const revisionV3 = value.schema === 'lattice.phase_todo_revision.v3';
|
|
812
|
+
if (!revisionV1 && !revisionV2 && !revisionV3) return reject('schema_mismatch', '/schema');
|
|
813
|
+
const keyCheck = explainKeys(value, revisionV3 ? PHASE_REVISION_V3_KEYS : PHASE_REVISION_KEYS, '');
|
|
814
|
+
if (!keyCheck.valid) return keyCheck;
|
|
815
|
+
if (!isTodoIdentifier(value.project_id)) return reject('invalid_identifier', '/project_id');
|
|
816
|
+
if (!isTodoIdentifier(value.plan_key)) return reject('invalid_identifier', '/plan_key');
|
|
817
|
+
const predecessorCheck = explainPredecessor(value.predecessor);
|
|
818
|
+
if (!predecessorCheck.valid) return predecessorCheck;
|
|
819
|
+
if (!validateTodoPlan(value.desired_plan)) return reject('desired_plan_invalid', '/desired_plan');
|
|
820
|
+
const expectedPlanSchema = (revisionV2 || revisionV3) ? 'lattice.todo_plan.v5' : 'lattice.todo_plan.v4';
|
|
821
|
+
if (value.desired_plan.schema !== expectedPlanSchema) {
|
|
822
|
+
return reject('desired_plan_schema_mismatch', '/desired_plan/schema');
|
|
823
|
+
}
|
|
824
|
+
if (value.desired_plan.project_id !== value.project_id) {
|
|
825
|
+
return reject('desired_plan_project_id_mismatch', '/desired_plan/project_id');
|
|
826
|
+
}
|
|
827
|
+
if (value.desired_plan.plan_key !== value.plan_key) {
|
|
828
|
+
return reject('desired_plan_plan_key_mismatch', '/desired_plan/plan_key');
|
|
829
|
+
}
|
|
830
|
+
if (value.desired_plan.predecessor_plan_digest !== value.predecessor.plan_digest) {
|
|
831
|
+
return reject('desired_plan_predecessor_mismatch', '/desired_plan/predecessor_plan_digest');
|
|
832
|
+
}
|
|
833
|
+
const taskMigrationCheck = explainTaskMigration(value.task_migration);
|
|
834
|
+
if (!taskMigrationCheck.valid) return taskMigrationCheck;
|
|
835
|
+
const phaseMigrationCheck = explainPhaseMigration(value.phase_migration, value.desired_plan);
|
|
836
|
+
if (!phaseMigrationCheck.valid) return phaseMigrationCheck;
|
|
837
|
+
const expectedPlanVersion = phaseTodoRevisionPlanVersion({
|
|
838
|
+
projectId: value.project_id, planKey: value.plan_key, predecessor: value.predecessor,
|
|
839
|
+
desiredPlan: value.desired_plan, taskMigration: value.task_migration,
|
|
840
|
+
phaseMigration: value.phase_migration,
|
|
841
|
+
});
|
|
842
|
+
if (value.desired_plan.plan_version !== expectedPlanVersion) {
|
|
843
|
+
return reject('plan_version_mismatch', '/desired_plan/plan_version');
|
|
844
|
+
}
|
|
845
|
+
if (revisionV3) {
|
|
846
|
+
const runtimeCheck = explainRuntimeTaskMigration(
|
|
847
|
+
value.runtime_task_migration, value.task_migration, value.desired_plan,
|
|
848
|
+
);
|
|
849
|
+
if (!runtimeCheck.valid) return runtimeCheck;
|
|
850
|
+
const sourceInventoryCheck = explainSourceInventory(value.source_inventory, value.desired_plan, {
|
|
851
|
+
requireNarrativeRef: true,
|
|
852
|
+
});
|
|
853
|
+
if (!sourceInventoryCheck.valid) return sourceInventoryCheck;
|
|
854
|
+
const cutoverCheck = explainSourceCutoverBatch(value.source_cutover_batch, value);
|
|
855
|
+
if (!cutoverCheck.valid) return cutoverCheck;
|
|
856
|
+
const reconciliationKeys = [
|
|
857
|
+
'predecessor_reconciliation_digest', 'source_inventory_digest', 'desired_plan_digest',
|
|
858
|
+
'runtime_task_migration_digest', 'task_migration_digest', 'phase_migration_digest',
|
|
859
|
+
'source_cutover_batch_digest', 'reconciliation_digest',
|
|
860
|
+
];
|
|
861
|
+
const reconciliationCheck = explainKeys(value.reconciliation, reconciliationKeys, '/reconciliation');
|
|
862
|
+
if (!reconciliationCheck.valid) return reconciliationCheck;
|
|
863
|
+
if (!isTodoDigest(value.reconciliation.predecessor_reconciliation_digest)) {
|
|
864
|
+
return reject('invalid_digest', '/reconciliation/predecessor_reconciliation_digest');
|
|
865
|
+
}
|
|
866
|
+
if (value.reconciliation.source_inventory_digest
|
|
867
|
+
!== todoSourceInventoryDigest(value.source_inventory)) {
|
|
868
|
+
return reject('source_inventory_digest_mismatch', '/reconciliation/source_inventory_digest');
|
|
869
|
+
}
|
|
870
|
+
if (value.reconciliation.desired_plan_digest !== value.desired_plan.plan_digest) {
|
|
871
|
+
return reject('desired_plan_digest_mismatch', '/reconciliation/desired_plan_digest');
|
|
872
|
+
}
|
|
873
|
+
if (value.reconciliation.runtime_task_migration_digest !== value.runtime_task_migration.migration_digest) {
|
|
874
|
+
return reject('runtime_task_migration_digest_mismatch', '/reconciliation/runtime_task_migration_digest');
|
|
875
|
+
}
|
|
876
|
+
if (value.reconciliation.task_migration_digest !== todoTaskMigrationDigest(value.task_migration)) {
|
|
877
|
+
return reject('task_migration_digest_mismatch', '/reconciliation/task_migration_digest');
|
|
878
|
+
}
|
|
879
|
+
if (value.reconciliation.phase_migration_digest !== digestTodoArtifact(value.phase_migration)) {
|
|
880
|
+
return reject('phase_migration_digest_mismatch', '/reconciliation/phase_migration_digest');
|
|
881
|
+
}
|
|
882
|
+
if (value.reconciliation.source_cutover_batch_digest !== value.source_cutover_batch.batch_digest) {
|
|
883
|
+
return reject('source_cutover_batch_digest_mismatch', '/reconciliation/source_cutover_batch_digest');
|
|
884
|
+
}
|
|
885
|
+
const expectedReconciliationDigest = todoSelfDigest(value.reconciliation, 'reconciliation_digest');
|
|
886
|
+
if (value.reconciliation.reconciliation_digest !== expectedReconciliationDigest) {
|
|
887
|
+
return reject('reconciliation_digest_mismatch', '/reconciliation/reconciliation_digest');
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (!isTodoDigest(value.revision_digest)) return reject('invalid_digest', '/revision_digest');
|
|
891
|
+
const expectedRevisionDigest = todoSelfDigest(value, 'revision_digest');
|
|
892
|
+
if (value.revision_digest !== expectedRevisionDigest) {
|
|
893
|
+
return reject('revision_digest_mismatch', '/revision_digest');
|
|
894
|
+
}
|
|
895
|
+
return { valid: true };
|
|
896
|
+
} catch {
|
|
897
|
+
return reject('diagnosis_failed', '');
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* `lattice todo revise-set`が受理する`lattice.todo_revision_set.v1/v2/v3`を診断する。
|
|
903
|
+
* 個々のrevision memberの中身は`explainTodoRevision`/`explainPhaseTodoRevision`へ委譲し、
|
|
904
|
+
* setとして必要な件数・plan_key順序・自己digestだけをここで見る。
|
|
905
|
+
*/
|
|
906
|
+
export function explainTodoRevisionSet(value) {
|
|
907
|
+
try {
|
|
908
|
+
if (!plainObject(value)) return reject('not_an_object', '');
|
|
909
|
+
const setV1 = value.schema === 'lattice.todo_revision_set.v1';
|
|
910
|
+
const setV2 = value.schema === 'lattice.todo_revision_set.v2';
|
|
911
|
+
const setV3 = value.schema === 'lattice.todo_revision_set.v3';
|
|
912
|
+
if (!setV1 && !setV2 && !setV3) return reject('schema_mismatch', '/schema');
|
|
913
|
+
const keyCheck = explainKeys(value, ['schema', 'project_id', 'revisions', 'revision_set_digest'], '');
|
|
914
|
+
if (!keyCheck.valid) return keyCheck;
|
|
915
|
+
if (!isTodoIdentifier(value.project_id)) return reject('invalid_identifier', '/project_id');
|
|
916
|
+
if (!Array.isArray(value.revisions) || value.revisions.length < 2 || value.revisions.length > 64) {
|
|
917
|
+
return reject('bounded_collection_violation', '/revisions');
|
|
918
|
+
}
|
|
919
|
+
for (const [index, revision] of value.revisions.entries()) {
|
|
920
|
+
const entryAt = `/revisions/${index}`;
|
|
921
|
+
const isPhaseMember = setV3 && ['lattice.phase_todo_revision.v1', 'lattice.phase_todo_revision.v2']
|
|
922
|
+
.includes(revision?.schema);
|
|
923
|
+
if (isPhaseMember) {
|
|
924
|
+
const memberCheck = explainPhaseTodoRevision(revision);
|
|
925
|
+
if (!memberCheck.valid) {
|
|
926
|
+
return reject(memberCheck.reason, `${entryAt}${memberCheck.path}`);
|
|
927
|
+
}
|
|
928
|
+
} else {
|
|
929
|
+
if (!setV2 && !setV3 && revision?.schema !== 'lattice.todo_revision.v1') {
|
|
930
|
+
return reject('revision_set_v1_requires_todo_revision_v1', `${entryAt}/schema`);
|
|
931
|
+
}
|
|
932
|
+
const memberCheck = explainTodoRevision(revision);
|
|
933
|
+
if (!memberCheck.valid) {
|
|
934
|
+
return reject(memberCheck.reason, `${entryAt}${memberCheck.path}`);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (revision.project_id !== value.project_id) {
|
|
938
|
+
return reject('revision_project_id_mismatch', `${entryAt}/project_id`);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
if (setV2 && !value.revisions.some((revision) => revision.schema === 'lattice.todo_revision.v2')) {
|
|
942
|
+
return reject('revision_set_v2_requires_todo_revision_v2_member', '/revisions');
|
|
943
|
+
}
|
|
944
|
+
if (setV3 && !value.revisions.some((revision) => [
|
|
945
|
+
'lattice.phase_todo_revision.v1', 'lattice.phase_todo_revision.v2',
|
|
946
|
+
].includes(revision.schema))) {
|
|
947
|
+
return reject('revision_set_v3_requires_phase_todo_revision_member', '/revisions');
|
|
948
|
+
}
|
|
949
|
+
for (let index = 1; index < value.revisions.length; index += 1) {
|
|
950
|
+
if (compareText(value.revisions[index - 1].plan_key, value.revisions[index].plan_key) >= 0) {
|
|
951
|
+
return reject('unsorted_or_duplicate_collection', `/revisions/${index}/plan_key`);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
if (!isTodoDigest(value.revision_set_digest)) return reject('invalid_digest', '/revision_set_digest');
|
|
955
|
+
const expectedDigest = todoSelfDigest(value, 'revision_set_digest');
|
|
956
|
+
if (value.revision_set_digest !== expectedDigest) {
|
|
957
|
+
return reject('revision_set_digest_mismatch', '/revision_set_digest');
|
|
958
|
+
}
|
|
959
|
+
return { valid: true };
|
|
960
|
+
} catch {
|
|
961
|
+
return reject('diagnosis_failed', '');
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
399
965
|
export function validateTodoRevisionSet(value) {
|
|
400
966
|
try {
|
|
401
967
|
const setV1 = value?.schema === 'lattice.todo_revision_set.v1';
|
package/src/todo-status.mjs
CHANGED
|
@@ -182,8 +182,10 @@ function buildTodoGraph(readModel) {
|
|
|
182
182
|
const nodes = new Map();
|
|
183
183
|
const incoming = new Map();
|
|
184
184
|
const memberHeads = [];
|
|
185
|
+
// snapshot artifactの形式(v1にはphasesキーが無い)には縛られない導出ビューを読む
|
|
186
|
+
// (readTodoStoreが常にmember.phasesとして埋める。ADR 0147)。
|
|
185
187
|
const phaseStatuses = new Map(readModel.members.flatMap((member) => (
|
|
186
|
-
(member.
|
|
188
|
+
(member.phases ?? []).map((phase) => [
|
|
187
189
|
`${member.plan.project_id}\0${member.plan.plan_key}\0${phase.phase_id}`, phase.status,
|
|
188
190
|
])
|
|
189
191
|
)));
|
|
@@ -224,7 +226,8 @@ function buildTodoGraph(readModel) {
|
|
|
224
226
|
}),
|
|
225
227
|
});
|
|
226
228
|
const states = new Map(member.tasks.map((state) => [state.task_id, state]));
|
|
227
|
-
|
|
229
|
+
// snapshot artifactの形式には縛られない導出ビュー(member.phases)を読む(ADR 0147)。
|
|
230
|
+
const phases = new Map((member.phases ?? []).map((state) => [state.phase_id, state]));
|
|
228
231
|
for (const task of member.plan.tasks) {
|
|
229
232
|
const state = states.get(task.task_id);
|
|
230
233
|
if (!plain(state) || !['pending', 'in-progress', 'blocked', 'done'].includes(state.status)) {
|