@quolu/lattice 0.103.0 → 0.105.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.md +17 -0
- package/package.json +1 -1
- package/src/cli-help.mjs +49 -8
- package/src/cli-refusal-guidance.mjs +18 -3
- package/src/project-cli.mjs +2 -1
- package/src/todo-cli.mjs +259 -25
- package/src/todo-contracts.mjs +34 -17
- package/src/todo-gantt-html-independence.mjs +2 -2
- package/src/todo-gantt-html-shared.mjs +30 -1
- package/src/todo-gantt-html-style.mjs +1 -0
- package/src/todo-gantt-html.mjs +7 -4
- package/src/todo-gantt-layout.mjs +2 -0
- package/src/todo-independence-guidance.mjs +2 -2
- package/src/todo-migration.mjs +5 -6
- package/src/todo-note-store.mjs +21 -3
- package/src/todo-notice-store.mjs +2 -2
- package/src/todo-notices.mjs +12 -1
- package/src/todo-readiness.mjs +53 -7
- package/src/todo-revision.mjs +12 -13
- package/src/todo-status.mjs +46 -7
- package/src/todo-store-view.mjs +59 -0
- package/src/todo-store.mjs +184 -45
- package/src/todo-version-compact.mjs +110 -0
package/src/todo-contracts.mjs
CHANGED
|
@@ -19,13 +19,20 @@ export const TODO_EVENT_KINDS = Object.freeze([
|
|
|
19
19
|
// 誤って張った接続の除去(connectの対・2026-08-29オーナー裁定系)。対象eventのdigestを指す
|
|
20
20
|
// tombstoneとして積み、projectionが両方を読んで線を消す。歴史は書き換えない。
|
|
21
21
|
'cross_plan_dependency_removed',
|
|
22
|
+
// 接続(他条件に接続): a task waits on a BellTeam schedule outside its own chart. Plan-scoped like the
|
|
23
|
+
// dependency ledger; removed/resolved point at the connection_added digest and each add has at most one end.
|
|
24
|
+
'connection_added', 'connection_removed', 'connection_resolved',
|
|
22
25
|
]);
|
|
23
26
|
|
|
24
27
|
/** planへ帰属し、taskにもPhaseにも属さないevent kind。 */
|
|
25
28
|
export const TODO_PLAN_SCOPED_EVENT_KINDS = Object.freeze([
|
|
26
29
|
'coordination_mode', 'cross_plan_dependency', 'cross_plan_dependency_removed',
|
|
30
|
+
'connection_added', 'connection_removed', 'connection_resolved',
|
|
27
31
|
]);
|
|
28
32
|
|
|
33
|
+
/** The schedule id is opaque to Lattice: printable ASCII without spaces. */
|
|
34
|
+
export const TODO_CONNECTION_SCHEDULE_ID = /^[!-~]{1,128}$/u;
|
|
35
|
+
|
|
29
36
|
/** 調整方式。witness=独立性を宣言し検証して並列する/conversation=会話で調整する。 */
|
|
30
37
|
// ADR 0200: `enforced` is witness coordination plus the gates that stop skipped steps.
|
|
31
38
|
export const TODO_COORDINATION_MODES = Object.freeze(['witness', 'conversation', 'enforced']);
|
|
@@ -52,9 +59,9 @@ export const TODO_CHART_META_SCHEMA = 'lattice.chart_meta.v1';
|
|
|
52
59
|
*/
|
|
53
60
|
export const TODO_NOTE_CONTEXT_SCHEMA = 'lattice.todo_note_context.v2';
|
|
54
61
|
export const TODO_LIMITS = Object.freeze({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
// ADR 0201: no count caps on a plan's tasks, edges, joins or phases; its size is bounded by bytes (snapshotBytes).
|
|
63
|
+
// The note context keeps its own entry count next to noteContextBytes.
|
|
64
|
+
noteContextEntries: 512,
|
|
58
65
|
journalSegmentBytes: 1_048_576,
|
|
59
66
|
snapshotBytes: 8_388_608,
|
|
60
67
|
narrativeSectionBytes: 262_144,
|
|
@@ -210,7 +217,7 @@ export function validateTodoNoteContext(value) {
|
|
|
210
217
|
]) || value.schema !== TODO_NOTE_CONTEXT_SCHEMA
|
|
211
218
|
|| !isTodoIdentifier(value.project_id) || !isTodoIdentifier(value.plan_key)
|
|
212
219
|
|| !isTodoIdentifier(value.task_id) || !Array.isArray(value.notes)
|
|
213
|
-
|| value.notes.length > TODO_LIMITS.
|
|
220
|
+
|| value.notes.length > TODO_LIMITS.noteContextEntries || !value.notes.every(noteContextEntry)
|
|
214
221
|
|| !(value.note_head_digest === null || isTodoDigest(value.note_head_digest))
|
|
215
222
|
|| !(value.plan_note_head_digest === null || isTodoDigest(value.plan_note_head_digest))
|
|
216
223
|
|| !isNonNegativeSafeInteger(value.overflow_count)
|
|
@@ -479,25 +486,24 @@ export function explainTodoPlan(value) {
|
|
|
479
486
|
if (!isTodoIdentifier(value[field])) return reject('identifier_invalid', `/${field}`);
|
|
480
487
|
}
|
|
481
488
|
if (!nullableDigest(value.predecessor_plan_digest)) return reject('digest_invalid', '/predecessor_plan_digest');
|
|
482
|
-
if (!Array.isArray(value.tasks) || value.tasks.length === 0
|
|
483
|
-
|| value.tasks.length > TODO_LIMITS.tasksPerPlan) return reject('bounded_collection_violation', '/tasks');
|
|
489
|
+
if (!Array.isArray(value.tasks) || value.tasks.length === 0) return reject('bounded_collection_violation', '/tasks');
|
|
484
490
|
const invalidTask = value.tasks.findIndex((task) => !taskValidator(task));
|
|
485
491
|
if (invalidTask >= 0) return reject('task_shape_invalid', `/tasks/${invalidTask}`);
|
|
486
492
|
if (new Set(value.tasks.map(({ task_id }) => task_id)).size !== value.tasks.length) {
|
|
487
493
|
return reject('duplicate_task_id', '/tasks');
|
|
488
494
|
}
|
|
489
|
-
if (!Array.isArray(value.hard_dependencies)
|
|
495
|
+
if (!Array.isArray(value.hard_dependencies)) {
|
|
490
496
|
return reject('bounded_collection_violation', '/hard_dependencies');
|
|
491
497
|
}
|
|
492
498
|
const invalidEdge = value.hard_dependencies.findIndex((edge) => !exactRecord(edge, ['from', 'to'])
|
|
493
499
|
|| !nodeRef(edge.from) || !nodeRef(edge.to));
|
|
494
500
|
if (invalidEdge >= 0) return reject('edge_shape_invalid', `/hard_dependencies/${invalidEdge}`);
|
|
495
|
-
if (!Array.isArray(value.joins)
|
|
501
|
+
if (!Array.isArray(value.joins)) {
|
|
496
502
|
return reject('bounded_collection_violation', '/joins');
|
|
497
503
|
}
|
|
498
504
|
const invalidJoin = value.joins.findIndex((join) => !exactRecord(join, ['id', 'after', 'before'])
|
|
499
505
|
|| !isTodoIdentifier(join.id) || !Array.isArray(join.after) || join.after.length === 0
|
|
500
|
-
||
|
|
506
|
+
|| !join.after.every(nodeRef) || !nodeRef(join.before));
|
|
501
507
|
if (invalidJoin >= 0) return reject('join_shape_invalid', `/joins/${invalidJoin}`);
|
|
502
508
|
for (const field of ['topology_digest', 'plan_digest']) {
|
|
503
509
|
if (!isTodoDigest(value[field])) return reject('digest_invalid', `/${field}`);
|
|
@@ -506,8 +512,7 @@ export function explainTodoPlan(value) {
|
|
|
506
512
|
'lattice.todo_plan.v6', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(value.schema)
|
|
507
513
|
&& !validParentGraph(value.tasks)) return reject('parent_graph_invalid', '/tasks');
|
|
508
514
|
if (phased) {
|
|
509
|
-
if (!Array.isArray(value.phases) || value.phases.length === 0
|
|
510
|
-
|| value.phases.length > TODO_LIMITS.tasksPerPlan) return reject('bounded_collection_violation', '/phases');
|
|
515
|
+
if (!Array.isArray(value.phases) || value.phases.length === 0) return reject('bounded_collection_violation', '/phases');
|
|
511
516
|
const invalidPhase = value.phases.findIndex((phase) => !phaseV1(phase));
|
|
512
517
|
if (invalidPhase >= 0) return reject('phase_shape_invalid', `/phases/${invalidPhase}`);
|
|
513
518
|
const order = explainTodoOrder(value.phases, (phase) => phase.phase_id, '/phases');
|
|
@@ -517,8 +522,7 @@ export function explainTodoPlan(value) {
|
|
|
517
522
|
if (!validPhaseGraph(value.phases)) return reject('phase_graph_invalid', '/phases');
|
|
518
523
|
}
|
|
519
524
|
if (decoupled) {
|
|
520
|
-
if (!Array.isArray(value.phase_accept_dependencies)
|
|
521
|
-
|| value.phase_accept_dependencies.length > TODO_LIMITS.edgesPerPlan) {
|
|
525
|
+
if (!Array.isArray(value.phase_accept_dependencies)) {
|
|
522
526
|
return reject('bounded_collection_violation', '/phase_accept_dependencies');
|
|
523
527
|
}
|
|
524
528
|
const invalid = value.phase_accept_dependencies.findIndex((edge) => !exactRecord(edge, ['from', 'to'])
|
|
@@ -567,7 +571,6 @@ function validPayload(event) {
|
|
|
567
571
|
])) && (payload.historical_import === undefined || payload.historical_import === true)
|
|
568
572
|
&& isTodoDigest(payload.plan_digest) && isTodoDigest(payload.topology_digest)
|
|
569
573
|
&& nullableDigest(payload.predecessor_plan_digest) && Array.isArray(payload.task_migration)
|
|
570
|
-
&& payload.task_migration.length <= TODO_LIMITS.tasksPerPlan
|
|
571
574
|
&& payload.task_migration.every((entry) => exactRecord(entry, ['from_task_id', 'to_task_id'])
|
|
572
575
|
&& isTodoIdentifier(entry.from_task_id) && (entry.to_task_id === 'removed' || isTodoIdentifier(entry.to_task_id)));
|
|
573
576
|
if (event.kind === 'start' && payload?.start_mode === 'historical_import') {
|
|
@@ -595,6 +598,20 @@ function validPayload(event) {
|
|
|
595
598
|
&& isTodoDigest(payload.target_event_digest)
|
|
596
599
|
&& nullableText(payload.reason) && payload.reason !== null;
|
|
597
600
|
}
|
|
601
|
+
if (event.kind === 'connection_added') {
|
|
602
|
+
return exactRecord(payload, ['task_id', 'to', 'reason']) && isTodoIdentifier(payload.task_id)
|
|
603
|
+
&& exactRecord(payload.to, ['kind', 'id']) && payload.to.kind === 'schedule'
|
|
604
|
+
&& typeof payload.to.id === 'string' && TODO_CONNECTION_SCHEDULE_ID.test(payload.to.id)
|
|
605
|
+
&& nullableText(payload.reason) && payload.reason !== null;
|
|
606
|
+
}
|
|
607
|
+
if (event.kind === 'connection_removed') {
|
|
608
|
+
return exactRecord(payload, ['target_event_digest', 'reason']) && isTodoDigest(payload.target_event_digest)
|
|
609
|
+
&& nullableText(payload.reason) && payload.reason !== null;
|
|
610
|
+
}
|
|
611
|
+
if (event.kind === 'connection_resolved') {
|
|
612
|
+
return exactRecord(payload, ['target_event_digest', 'evidence']) && isTodoDigest(payload.target_event_digest)
|
|
613
|
+
&& nullableText(payload.evidence) && payload.evidence !== null;
|
|
614
|
+
}
|
|
598
615
|
// rebind: plan改訂でcarryされたin-progress ToDoへ、現plan_versionの明示的start束縛を積み直す
|
|
599
616
|
// (runtime intakeはliteral startだけを束縛に使い、carryを推定しない。ADR 0191)
|
|
600
617
|
if (event.kind === 'start' && payload?.start_mode === 'rebind') {
|
|
@@ -699,7 +716,7 @@ function validCarriedState(value) {
|
|
|
699
716
|
}
|
|
700
717
|
|
|
701
718
|
function validStateMigration(value) {
|
|
702
|
-
return Array.isArray(value)
|
|
719
|
+
return Array.isArray(value)
|
|
703
720
|
&& value.every((entry) => exactRecord(entry, [
|
|
704
721
|
'from_task_id', 'to_task_id', 'state_policy', 'state',
|
|
705
722
|
]) && isTodoIdentifier(entry.from_task_id)
|
|
@@ -715,7 +732,7 @@ function validStateMigration(value) {
|
|
|
715
732
|
}
|
|
716
733
|
|
|
717
734
|
function validPhaseStateMigration(value) {
|
|
718
|
-
return Array.isArray(value)
|
|
735
|
+
return Array.isArray(value)
|
|
719
736
|
&& value.every((entry) => exactRecord(entry, ['phase_id', 'state_policy', 'state'])
|
|
720
737
|
&& isTodoIdentifier(entry.phase_id) && ['carry', 'reset'].includes(entry.state_policy)
|
|
721
738
|
&& (entry.state_policy === 'reset' ? entry.state === null
|
|
@@ -824,7 +841,7 @@ export function validateTodoSnapshot(value) {
|
|
|
824
841
|
&& value.projection_version === (v1 ? 1 : v2 ? 2 : v3 ? 3 : 4)
|
|
825
842
|
&& isNonNegativeSafeInteger(value.through_sequence)
|
|
826
843
|
&& isTodoDigest(value.journal_head_digest) && Array.isArray(value.tasks)
|
|
827
|
-
&& value.tasks.length > 0
|
|
844
|
+
&& value.tasks.length > 0
|
|
828
845
|
&& value.tasks.every((entry) => exactRecord(entry, [
|
|
829
846
|
'task_id', 'status', 'started_at', 'done_at', 'blocked_reason', 'evidence', 'evidence_unverified', 'imported',
|
|
830
847
|
...(resultAware ? ['test_result'] : []),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DOCUMENT_STATUS, SEVERABILITY_LABEL, escapeHtmlAttribute, escapeHtmlText, foldIndex, planActivity, presentationLookup, refKey, renderPhaseProgress, renderRelationList, renderSeamProposalOverview, renderTaskIndex, statusMarkup, taskReference } from './todo-gantt-html-shared.mjs';
|
|
1
|
+
import { DOCUMENT_STATUS, SEVERABILITY_LABEL, escapeHtmlAttribute, escapeHtmlText, foldIndex, planActivity, presentationLookup, refKey, renderConnectionArea, renderPhaseProgress, renderRelationList, renderSeamProposalOverview, renderTaskIndex, statusMarkup, taskReference } from './todo-gantt-html-shared.mjs';
|
|
2
2
|
import {
|
|
3
3
|
hasTodoStructurePresentation,
|
|
4
4
|
renderTodoStructureNoscript,
|
|
@@ -254,7 +254,7 @@ export function renderRightPane(
|
|
|
254
254
|
: '<p class="fold-note">完走済みのため図には描いていません。図に出すには動的dashboardを <code>lattice todo gantt serve --port <port> --scope all</code> で起動してください。</p>';
|
|
255
255
|
const workLog = notesEnabled ? renderNoteContext(section.noteContext, hostDisplayNames) : '';
|
|
256
256
|
const designMemo = renderDesignMemo(section.task) + renderDoneCondition(section.task);
|
|
257
|
-
return `<article class="task-detail" data-detail-key="${escapeHtmlAttribute(key)}" hidden><header><span class="detail-status status-${escapeHtmlAttribute(section.state.status)}">${escapeHtmlText(status.mark)} ${escapeHtmlText(status.label)}</span><span class="detail-reference">${escapeHtmlText(taskReference(section, lookup))}</span></header><h1>${escapeHtmlText(section.task.title)}</h1><p class="detail-category"><strong>カテゴリ:</strong> ${escapeHtmlText(category)}</p>${categoryDescription}<p><strong>正規ID:</strong> <code>${escapeHtmlText(`${section.ref.plan_key}/${section.task.task_id}`)}</code></p>${blockedReason}${readiness}${independenceNote}${foldedNote}${designMemo}<section><h2>前提工程</h2>${renderRelationList(incoming.get(key), sectionByKey, lookup, '登録済みの前提工程はありません。', folds)}</section><section><h2>後続工程</h2>${renderRelationList(outgoing.get(key), sectionByKey, lookup, '登録済みの後続工程はありません。', folds)}</section>${workLog}<p class="anchor-status">${escapeHtmlText(anchorText)}</p><details class="task-diagnostics"><summary>開発者向け診断</summary><dl><dt>canonical ref</dt><dd><code>${escapeHtmlText(`${section.ref.project_id}/${section.ref.plan_key}/${section.task.task_id}`)}</code></dd><dt>anchor</dt><dd>${escapeHtmlText(section.anchorOutcome.anchored ? 'verified' : section.anchorOutcome.reason)}</dd></dl></details></article>`;
|
|
257
|
+
return `<article class="task-detail" data-detail-key="${escapeHtmlAttribute(key)}" hidden><header><span class="detail-status status-${escapeHtmlAttribute(section.state.status)}">${escapeHtmlText(status.mark)} ${escapeHtmlText(status.label)}</span><span class="detail-reference">${escapeHtmlText(taskReference(section, lookup))}</span></header><h1>${escapeHtmlText(section.task.title)}</h1><p class="detail-category"><strong>カテゴリ:</strong> ${escapeHtmlText(category)}</p>${categoryDescription}<p><strong>正規ID:</strong> <code>${escapeHtmlText(`${section.ref.plan_key}/${section.task.task_id}`)}</code></p>${blockedReason}${renderConnectionArea(section.connections)}${readiness}${independenceNote}${foldedNote}${designMemo}<section><h2>前提工程</h2>${renderRelationList(incoming.get(key), sectionByKey, lookup, '登録済みの前提工程はありません。', folds)}</section><section><h2>後続工程</h2>${renderRelationList(outgoing.get(key), sectionByKey, lookup, '登録済みの後続工程はありません。', folds)}</section>${workLog}<p class="anchor-status">${escapeHtmlText(anchorText)}</p><details class="task-diagnostics"><summary>開発者向け診断</summary><dl><dt>canonical ref</dt><dd><code>${escapeHtmlText(`${section.ref.project_id}/${section.ref.plan_key}/${section.task.task_id}`)}</code></dd><dt>anchor</dt><dd>${escapeHtmlText(section.anchorOutcome.anchored ? 'verified' : section.anchorOutcome.reason)}</dd></dl></details></article>`;
|
|
258
258
|
}).join('');
|
|
259
259
|
const taskIndex = renderTaskIndex(sections, lookup, folds, planActivity(readModel));
|
|
260
260
|
const structureButton = hasTodoStructurePresentation(structurePresentation)
|
|
@@ -44,6 +44,35 @@ export function foldIndex(layout) {
|
|
|
44
44
|
return new Set((layout?.folded ?? []).map((ref) => refKey(ref)));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// One 接続 area per task (Owner 2026-11-15): 他条件に接続 (task/schedule) and 優先接続 (priority) side by side, from the
|
|
48
|
+
// single `connections` list; ブロック中 is drawn where it was.
|
|
49
|
+
const CONNECTION_LABEL = Object.freeze({ task: '他条件に接続', schedule: '他条件に接続', priority: '優先接続' });
|
|
50
|
+
const CONNECTION_TARGET = Object.freeze({ task: '工程', schedule: '予定' });
|
|
51
|
+
|
|
52
|
+
function connectionLine(entry) {
|
|
53
|
+
const label = CONNECTION_LABEL[entry.kind] ?? '接続';
|
|
54
|
+
const settled = entry.state === 'settled';
|
|
55
|
+
const target = entry.kind === 'priority'
|
|
56
|
+
? `${entry.agent}(着手できるようになったら知らせを受ける)`
|
|
57
|
+
: `${CONNECTION_TARGET[entry.kind] ?? ''} <code>${escapeHtmlText(entry.ref)}</code>`;
|
|
58
|
+
const state = entry.kind === 'priority' ? '' : settled ? ' — 成立' : entry.state_reason === 'chart_not_read' ? ' — 開いている(その工程表を読めません)' : ' — 開いている';
|
|
59
|
+
const note = [entry.reason, settled ? entry.evidence : null].filter((text) => typeof text === 'string' && text.length > 0).map(escapeHtmlText).join(' / ');
|
|
60
|
+
return `<li class="connection connection-${escapeHtmlAttribute(entry.kind)}" data-state="${escapeHtmlAttribute(entry.state ?? 'open')}"><strong>${label}</strong> ${target}${state}${note === '' ? '' : ` — ${note}`}${entry.since ? ` <time>${escapeHtmlText(entry.since)}</time>` : ''}</li>`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The detail pane's 接続 area; empty when the task has no connections. */
|
|
64
|
+
export function renderConnectionArea(connections = []) {
|
|
65
|
+
return connections.length === 0 ? ''
|
|
66
|
+
: `<section class="connections" aria-label="接続"><h2>接続</h2><ul>${connections.map(connectionLine).join('')}</ul></section>`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The chip row: one chip per kind, counting the open 他条件に接続 and the 優先接続. */
|
|
70
|
+
export function renderConnectionChips(connections = []) {
|
|
71
|
+
const open = connections.filter((entry) => entry.kind !== 'priority' && entry.state !== 'settled').length;
|
|
72
|
+
const priority = connections.filter((entry) => entry.kind === 'priority').length;
|
|
73
|
+
return `${open === 0 ? '' : `<span class="connection-chip">他条件に接続 ${open}</span>`}${priority === 0 ? '' : '<span class="connection-chip">優先接続</span>'}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
47
76
|
export function renderTaskIndexEntry(section, lookup) {
|
|
48
77
|
const key = refKey(section.ref);
|
|
49
78
|
const status = DOCUMENT_STATUS[section.state.status] ?? { mark: '?', label: '状態不明' };
|
|
@@ -52,7 +81,7 @@ export function renderTaskIndexEntry(section, lookup) {
|
|
|
52
81
|
// A ToDo the diagram does not draw keeps its row here — the index is the
|
|
53
82
|
// complete list — and it selects its own detail, which exists either way.
|
|
54
83
|
const selectKey = key;
|
|
55
|
-
return `<li><button type="button" data-select-node-key="${escapeHtmlAttribute(selectKey)}"><span class="task-index-status status-${escapeHtmlAttribute(section.state.status)}" role="img" aria-label="${escapeHtmlAttribute(status.label)}">${escapeHtmlText(status.mark)}</span><span class="task-index-reference">${escapeHtmlText(taskReference(section, lookup))}</span><strong>${escapeHtmlText(section.task.title)}</strong>${blockedReason}</button></li>`;
|
|
84
|
+
return `<li><button type="button" data-select-node-key="${escapeHtmlAttribute(selectKey)}"><span class="task-index-status status-${escapeHtmlAttribute(section.state.status)}" role="img" aria-label="${escapeHtmlAttribute(status.label)}">${escapeHtmlText(status.mark)}</span><span class="task-index-reference">${escapeHtmlText(taskReference(section, lookup))}</span><strong>${escapeHtmlText(section.task.title)}</strong>${blockedReason}${renderConnectionChips(section.connections)}</button></li>`;
|
|
56
85
|
}
|
|
57
86
|
|
|
58
87
|
/** plan_key -> 最終活動時刻。journalの末尾eventが、そのplanが最後に動いた時点。 */
|
|
@@ -101,6 +101,7 @@ button.fold-chip[aria-expanded="true"]{border-color:var(--text-primary)}
|
|
|
101
101
|
.status-in-progress .status-bar{stroke:var(--accent);stroke-width:2;stroke-linecap:round}
|
|
102
102
|
.status-done .node-surface{fill:var(--surface-2);stroke:var(--border);stroke-width:1}
|
|
103
103
|
.status-done .status-mark{fill:var(--good)}
|
|
104
|
+
.connections ul{margin:4px 0 8px;padding-left:18px}.connection time{color:var(--text-secondary);font-size:12px;white-space:nowrap}.connection-chip{display:inline-block;margin-left:6px;padding:0 8px;border:1px solid var(--accent);border-radius:9999px;color:var(--accent);font-size:12px;white-space:nowrap}
|
|
104
105
|
.status-blocked .node-surface{fill:var(--surface-1);stroke:var(--critical);stroke-width:2}
|
|
105
106
|
.status-blocked .status-mark{fill:var(--critical)}
|
|
106
107
|
.next-ready-node .node-surface{stroke:var(--accent);stroke-width:2;stroke-dasharray:4 3}
|
package/src/todo-gantt-html.mjs
CHANGED
|
@@ -70,7 +70,8 @@ function digest(value) {
|
|
|
70
70
|
* still read, because anchor verification needs them, and their size is still
|
|
71
71
|
* bounded — but they are not rendered into the page.
|
|
72
72
|
*/
|
|
73
|
-
function normalizeSections(readModel, narratives, anchorOutcomes, noteContexts, omitProse = false) {
|
|
73
|
+
function normalizeSections(readModel, narratives, anchorOutcomes, noteContexts, omitProse = false, connections = []) {
|
|
74
|
+
const connected = new Map(connections.map((entry) => [refKey(entry), entry.connections]));
|
|
74
75
|
const supplied = new Map(narratives.map((entry) => [refKey(entry.ref), entry]));
|
|
75
76
|
const outcomes = new Map(anchorOutcomes.map((entry) => [refKey(entry.ref), entry]));
|
|
76
77
|
const notes = noteContexts === null ? null : new Map(noteContexts.map((entry) => [
|
|
@@ -123,6 +124,7 @@ function normalizeSections(readModel, narratives, anchorOutcomes, noteContexts,
|
|
|
123
124
|
}
|
|
124
125
|
result.push({
|
|
125
126
|
ref, task: shownTask, state: states.get(task.task_id), narrativeRef, anchorOutcome, noteContext,
|
|
127
|
+
connections: connected.get(refKey(ref)) ?? [],
|
|
126
128
|
});
|
|
127
129
|
}
|
|
128
130
|
}
|
|
@@ -216,8 +218,9 @@ const NESTED_CONTROLLER = `
|
|
|
216
218
|
export function renderTodoGanttHtml({
|
|
217
219
|
readModel, layout, narratives = [], anchorOutcomes = [], presentation = null, metadata = {},
|
|
218
220
|
expandedLayout = null, noteContexts = null, noteWarnings = [], structurePresentation = null,
|
|
219
|
-
notices = [],
|
|
221
|
+
notices = [], connections = [],
|
|
220
222
|
}) {
|
|
223
|
+
if (!Array.isArray(connections)) throw new TypeError('connections must be an array');
|
|
221
224
|
if (readModel?.schema !== 'lattice.todo_store_read.v1' || !Array.isArray(readModel.members)) {
|
|
222
225
|
throw new TypeError('readModel must be lattice.todo_store_read.v1');
|
|
223
226
|
}
|
|
@@ -262,13 +265,13 @@ export function renderTodoGanttHtml({
|
|
|
262
265
|
return html;
|
|
263
266
|
};
|
|
264
267
|
const layoutNotices = [...(layout?.notices ?? []), ...notices];
|
|
265
|
-
let normalized = normalizeSections(readModel, narratives, anchorOutcomes, noteContexts);
|
|
268
|
+
let normalized = normalizeSections(readModel, narratives, anchorOutcomes, noteContexts, false, connections);
|
|
266
269
|
let pageNotices = [...layoutNotices, ...normalized.notices];
|
|
267
270
|
let html = build(normalized, pageNotices);
|
|
268
271
|
let htmlBytes = Buffer.byteLength(html, 'utf8');
|
|
269
272
|
if (htmlBytes > TODO_GANTT_HTML_MAX_BYTES) {
|
|
270
273
|
// u03 D-gantt: draw the page without the embedded prose; if it is still over, serve it with the notice.
|
|
271
|
-
normalized = normalizeSections(readModel, narratives, anchorOutcomes, noteContexts, true);
|
|
274
|
+
normalized = normalizeSections(readModel, narratives, anchorOutcomes, noteContexts, true, connections);
|
|
272
275
|
pageNotices = [...layoutNotices, { code: 'TODO_SCALE_EXCEEDED',
|
|
273
276
|
message: 'ページ全体の大きさが上限を超えたため、設計メモ・終了条件・作業記録を省いて描いています',
|
|
274
277
|
detail: { html_bytes: htmlBytes, html_limit: TODO_GANTT_HTML_MAX_BYTES } }];
|
|
@@ -245,6 +245,8 @@ function normalizeInput(readModel) {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
for (const dependency of projectTodoCrossPlanDependencies(members)) {
|
|
248
|
+
// A task on another chart is a 接続: it lives in the task's `connections`, never as a drawn edge.
|
|
249
|
+
if (dependency.from.project_id !== dependency.to.project_id) continue;
|
|
248
250
|
addEdge(dependency.from, dependency.to, 'cross_plan');
|
|
249
251
|
}
|
|
250
252
|
if (skippedEdges.length > 0) {
|
|
@@ -104,11 +104,11 @@ const CATALOG = Object.freeze({
|
|
|
104
104
|
}),
|
|
105
105
|
independence_conflict_with_active: Object.freeze({
|
|
106
106
|
message: '作業中の工程と同じ資源を書く記録がある。並行すると衝突する。',
|
|
107
|
-
next_action: 'lattice todo
|
|
107
|
+
next_action: 'lattice todo predecessor add --plan <key> --task <id> --after <plan>/<task> --reason <text>',
|
|
108
108
|
}),
|
|
109
109
|
independence_conflict_between_ready: Object.freeze({
|
|
110
110
|
message: '他のready工程と同じ資源を書く記録がある。同時に着手すると衝突する。',
|
|
111
|
-
next_action: 'lattice todo
|
|
111
|
+
next_action: 'lattice todo predecessor add --plan <key> --task <id> --after <plan>/<task> --reason <text>',
|
|
112
112
|
}),
|
|
113
113
|
independence_verdicts_absent: Object.freeze({
|
|
114
114
|
message: '判定が途中で止まっており、記録はどの組についてもverdictを持たない。自分にunknownが無いことは、他と干渉しない証拠にならない。',
|
package/src/todo-migration.mjs
CHANGED
|
@@ -124,7 +124,7 @@ function isCrossPlanEdge(edge) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
function validateEdges(value, schema) {
|
|
127
|
-
return Array.isArray(value)
|
|
127
|
+
return Array.isArray(value)
|
|
128
128
|
&& value.every((edge) => {
|
|
129
129
|
const basic = exactRecord(edge, ['from', 'to']);
|
|
130
130
|
const refsValid = nodeRef(edge?.from) && nodeRef(edge?.to);
|
|
@@ -139,10 +139,10 @@ function validateEdges(value, schema) {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
function validateJoins(value) {
|
|
142
|
-
return Array.isArray(value)
|
|
142
|
+
return Array.isArray(value)
|
|
143
143
|
&& value.every((join) => exactRecord(join, ['id', 'after', 'before'])
|
|
144
144
|
&& isTodoIdentifier(join.id) && Array.isArray(join.after) && join.after.length > 0
|
|
145
|
-
&& join.after.
|
|
145
|
+
&& join.after.every(nodeRef)
|
|
146
146
|
&& sortedStrictly(join.after, refKey) && nodeRef(join.before))
|
|
147
147
|
&& sortedStrictly(value, (join) => join.id);
|
|
148
148
|
}
|
|
@@ -230,8 +230,7 @@ export function explainTodoExtraction(value) {
|
|
|
230
230
|
if (!isTodoIdentifier(value.plan_version)) return reject('invalid_identifier', '/plan_version');
|
|
231
231
|
if (!actor(value.actor)) return reject('invalid_actor', '/actor');
|
|
232
232
|
if (!isStrictTodoTimestamp(value.recorded_at)) return reject('invalid_timestamp', '/recorded_at');
|
|
233
|
-
if (!Array.isArray(value.tasks) || value.tasks.length
|
|
234
|
-
|| (value.tasks.length === 0 && !v4)) {
|
|
233
|
+
if (!Array.isArray(value.tasks) || (value.tasks.length === 0 && !v4)) {
|
|
235
234
|
return reject('bounded_collection_violation', '/tasks');
|
|
236
235
|
}
|
|
237
236
|
const taskKeys = v2
|
|
@@ -387,7 +386,7 @@ export function validateTodoExtraction(value) {
|
|
|
387
386
|
|| !isTodoIdentifier(value.project_id)
|
|
388
387
|
|| !isTodoIdentifier(value.plan_key) || !isTodoIdentifier(value.plan_version)
|
|
389
388
|
|| !actor(value.actor) || !isStrictTodoTimestamp(value.recorded_at)
|
|
390
|
-
|| !Array.isArray(value.tasks)
|
|
389
|
+
|| !Array.isArray(value.tasks)
|
|
391
390
|
|| (value.tasks.length === 0 && schema !== TODO_EXTRACTION_SCHEMA_V4)
|
|
392
391
|
|| !value.tasks.every((task) => extractionTask(task, schema))
|
|
393
392
|
|| !sortedStrictly(value.tasks, (task) => task.task_id)
|
package/src/todo-note-store.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { LOCK_WAIT_MS, StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
|
8
8
|
import { syncPublishedFile } from './fs-publish.mjs';
|
|
9
9
|
import { normalizeCheckoutEol } from './todo-store-view.mjs';
|
|
10
10
|
import { memoByFileIdentity } from './todo-version-memo.mjs';
|
|
11
|
+
import { TODO_VERSION_COMPACT_FILE, readVersionCompact } from './todo-version-compact.mjs';
|
|
11
12
|
|
|
12
13
|
import {
|
|
13
14
|
TODO_LIMITS,
|
|
@@ -446,7 +447,7 @@ export function projectTodoNoteContext(options = {}) {
|
|
|
446
447
|
let usedBytes = 0;
|
|
447
448
|
for (const entry of offered) {
|
|
448
449
|
// 件数もvalidatorと同じ上限で切る。byteに収まる短いnoteが溜まると、自分の出力が自分の検証で落ちる。
|
|
449
|
-
if (notes.length >= TODO_LIMITS.
|
|
450
|
+
if (notes.length >= TODO_LIMITS.noteContextEntries) break;
|
|
450
451
|
const bytes = Buffer.byteLength(entry.body, 'utf8');
|
|
451
452
|
if (usedBytes + bytes > TODO_LIMITS.noteContextBytes) continue;
|
|
452
453
|
notes.push(entry);
|
|
@@ -514,8 +515,25 @@ async function readNoteMigrations(repoRoot, planKey, eventVersions) {
|
|
|
514
515
|
const versionRoot = path.join(base, entry.name);
|
|
515
516
|
const planPath = path.join(versionRoot, 'plan.json');
|
|
516
517
|
const revisionPath = path.join(versionRoot, 'revision.json');
|
|
517
|
-
|
|
518
|
-
|
|
518
|
+
const compactPath = path.join(versionRoot, TODO_VERSION_COMPACT_FILE);
|
|
519
|
+
// perf-store: validated once per process while the files are unchanged (todo-version-memo).
|
|
520
|
+
const version = await memoByFileIdentity([planPath, revisionPath, compactPath], async () => {
|
|
521
|
+
// b10: a superseded version keeps compact.json.gz (its revision, minus the plan it repeats) instead of plan.json/revision.json.
|
|
522
|
+
const compact = await readVersionCompact(versionRoot).catch(() => fail('NOTE_PROJECTION_INVALID',
|
|
523
|
+
'note_historical_plan_invalid', { plan_version: entry.name }));
|
|
524
|
+
if (compact !== null) {
|
|
525
|
+
if (compact.plan_key !== planKey || compact.plan_version !== entry.name) {
|
|
526
|
+
fail('NOTE_PROJECTION_INVALID', 'note_historical_plan_invalid', { plan_version: entry.name });
|
|
527
|
+
}
|
|
528
|
+
const migration = compact.revision?.task_migration;
|
|
529
|
+
if (compact.revision === null) return { migration: null };
|
|
530
|
+
if (compact.predecessor_plan_version === null || !Array.isArray(migration)) {
|
|
531
|
+
fail('NOTE_PROJECTION_INVALID', 'note_historical_revision_invalid', { plan_version: entry.name });
|
|
532
|
+
}
|
|
533
|
+
return { migration: { from_plan_version: compact.predecessor_plan_version, to_plan_version: entry.name,
|
|
534
|
+
task_migration: migration.map(({ from_task_id: fromTaskId, to_task_id: toTaskId }) => ({
|
|
535
|
+
from_task_id: fromTaskId, to_task_id: toTaskId })) } };
|
|
536
|
+
}
|
|
519
537
|
// A revision directory is published before manifest activation. A crash during
|
|
520
538
|
// that window can leave an unreferenced directory containing only a journal
|
|
521
539
|
// stub. It is not a historical plan until its canonical plan artifact exists.
|
|
@@ -15,7 +15,7 @@ export { TODO_NOTICE_ACKS_SCHEMA, TODO_NOTICE_WAITS_SCHEMA };
|
|
|
15
15
|
* Per-lane ack set of startable notices and per-plan waits (dfd-done-notice.md, rows "Store: ack set",
|
|
16
16
|
* "Store: waits record", "Store: ack key"). Host-local delivery state, not a plan fact: git-ignored (its own
|
|
17
17
|
* .gitignore), one lock for both, never touching the lifecycle journals. Losing an ack means a notice is
|
|
18
|
-
* delivered again; losing a wait loses the wake mark (the notice still lists) until `todo
|
|
18
|
+
* delivered again; losing a wait loses the wake mark (the notice still lists) until `todo connect priority` runs again.
|
|
19
19
|
*/
|
|
20
20
|
export const TODO_NOTICE_ROOT_REF = '.lattice/todo/notices';
|
|
21
21
|
const ACKS_V1_SCHEMA = 'lattice.todo_notice_acks.v1';
|
|
@@ -101,7 +101,7 @@ const ACK_FILE = {
|
|
|
101
101
|
const WAIT_RECORD = {
|
|
102
102
|
family: 'todo_notice_waits', label: 'notice_waits', digest: 'waits_digest',
|
|
103
103
|
advice: 'is a host-local notice wait file, not plan data. Delete it to drop the plan\'s wake marks'
|
|
104
|
-
+ ' (re-run `lattice todo
|
|
104
|
+
+ ' (re-run `lattice todo connect priority` to restore one), or run `lattice todo connect priority` to replace it.',
|
|
105
105
|
parse(record) {
|
|
106
106
|
if (!exactRecord(record, ['schema', 'plan_key', 'waits', 'waits_digest']) || record.schema !== TODO_NOTICE_WAITS_SCHEMA
|
|
107
107
|
|| !isTodoIdentifier(record.plan_key) || !Array.isArray(record.waits) || !record.waits.every(isWait)
|
package/src/todo-notices.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Store journals. Lattice records and shows; a notice starts nothing and gates nothing.
|
|
3
3
|
|
|
4
4
|
import { digestTodoArtifact } from './todo-contracts.mjs';
|
|
5
|
-
import { todoNoticeWaitingDigest } from './todo-notice-store.mjs';
|
|
5
|
+
import { readAllTodoNoticeWaits, todoNoticeWaitingDigest } from './todo-notice-store.mjs';
|
|
6
6
|
import { createTodoReadiness } from './todo-readiness.mjs';
|
|
7
7
|
import { projectTodoStatus, TODO_STATUS_DISPATCH_ONLY } from './todo-status.mjs';
|
|
8
8
|
|
|
@@ -44,6 +44,17 @@ export function waitInEffect(store, wait) {
|
|
|
44
44
|
&& ['start', 'retire'].includes(event.kind) && event.recorded_at > wait.since);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* 優先接続: `store` plus `priority_waits`, the host-local `todo wait` marks still in effect (an unreadable file reads as
|
|
49
|
+
* none, as for notices), so every read surface draws the same `connections` list. Gates nothing.
|
|
50
|
+
*/
|
|
51
|
+
export async function withTodoPriorityWaits(store, { repoRoot }) {
|
|
52
|
+
if (store.priority_waits !== undefined) return store;
|
|
53
|
+
const stored = await readAllTodoNoticeWaits({ repoRoot });
|
|
54
|
+
return { ...store, priority_waits: stored.waits.flatMap((record) => record.waits
|
|
55
|
+
.map((wait) => ({ plan_key: record.plan_key, ...wait }))).filter((wait) => waitInEffect(store, wait)) };
|
|
56
|
+
}
|
|
57
|
+
|
|
47
58
|
function noticeSummary(planKey, task, waiting) {
|
|
48
59
|
const head = `${planKey}/${task.task_id} 「${task.title}」 can start now.`;
|
|
49
60
|
return waiting.length === 0
|
package/src/todo-readiness.mjs
CHANGED
|
@@ -2,7 +2,9 @@ import {
|
|
|
2
2
|
isDecoupledPhaseTodoPlanSchema,
|
|
3
3
|
isFinishedTodoTaskState,
|
|
4
4
|
isPhaseTodoPlanSchema,
|
|
5
|
+
projectTodoConnections,
|
|
5
6
|
projectTodoCrossPlanDependencies,
|
|
7
|
+
projectTodoScheduleConnections,
|
|
6
8
|
stepTodoReopenedPending,
|
|
7
9
|
} from './todo-store-view.mjs';
|
|
8
10
|
import { TodoStoreError, todoPhaseDefinitions } from './todo-store.mjs';
|
|
@@ -85,6 +87,19 @@ export function createTodoReadiness(store) {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
for (const edge of projectTodoCrossPlanDependencies(store.members)) connect(edge.from, edge.to);
|
|
90
|
+
// 接続: schedule targets and cross-chart task targets, per task; an open one keeps the task from starting.
|
|
91
|
+
const connectionsByTask = projectTodoConnections(store.members, store.external_tasks ?? []);
|
|
92
|
+
const connections = (key) => connectionsByTask.get(key) ?? [];
|
|
93
|
+
// 優先接続: the host-local `todo wait` mark (store.priority_waits, in-effect only). It gates nothing.
|
|
94
|
+
const priorityByTask = new Map();
|
|
95
|
+
for (const wait of store.priority_waits ?? []) {
|
|
96
|
+
const key = taskKey({ project_id: store.project_id, plan_key: wait.plan_key, task_id: wait.task_id });
|
|
97
|
+
priorityByTask.set(key, [...(priorityByTask.get(key) ?? []),
|
|
98
|
+
{ kind: 'priority', agent: wait.agent, since: wait.since, reason: wait.reason ?? null }]);
|
|
99
|
+
}
|
|
100
|
+
/** The one read-contract list: 他条件に接続 entries (gating) then 優先接続 entries (never gating). */
|
|
101
|
+
const allConnections = (key) => [...connections(key),
|
|
102
|
+
...(priorityByTask.get(key) ?? []).sort((left, right) => (left.agent < right.agent ? -1 : left.agent > right.agent ? 1 : 0))];
|
|
88
103
|
|
|
89
104
|
function dependencyPhaseReady(predecessor, target) {
|
|
90
105
|
if (predecessor === undefined) return false;
|
|
@@ -100,6 +115,8 @@ export function createTodoReadiness(store) {
|
|
|
100
115
|
const predecessors = [...(incoming.get(key) ?? [])].map(predecessorNode)
|
|
101
116
|
.filter((node) => node !== undefined);
|
|
102
117
|
const unfinished = predecessors.filter((node) => node.finished !== true);
|
|
118
|
+
// 前工程 = same chart; a task on another chart is a 接続 and is named in blocking_connections instead.
|
|
119
|
+
const unfinishedHere = unfinished.filter((node) => node.project_id === undefined);
|
|
103
120
|
const unreadyPhases = predecessors.filter((node) => !dependencyPhaseReady(node, nodes.get(key)));
|
|
104
121
|
const predecessorsDone = unfinished.length === 0;
|
|
105
122
|
const predecessorPhasesReady = unreadyPhases.length === 0;
|
|
@@ -107,21 +124,33 @@ export function createTodoReadiness(store) {
|
|
|
107
124
|
const unacceptedEdges = [...(acceptanceIncoming.get(key) ?? [])]
|
|
108
125
|
.map((source) => phases.get(source)).filter((phase) => phase !== undefined && phase.status !== 'accepted');
|
|
109
126
|
const phaseAcceptReady = unacceptedEdges.length === 0;
|
|
127
|
+
const openConnections = connections(key).filter(({ state }) => state === 'open');
|
|
128
|
+
// Only a schedule 接続 is an extra gate; a task 接続 is today's cross-chart edge, already in `unfinished`.
|
|
129
|
+
const scheduleOpen = openConnections.some(({ kind }) => kind === 'schedule');
|
|
130
|
+
const connectionsOpen = scheduleOpen || unfinished.some((node) => node.project_id !== undefined);
|
|
110
131
|
const cause = !phaseAcceptReady ? 'acceptance_edge'
|
|
111
|
-
:
|
|
112
|
-
:
|
|
132
|
+
: unfinishedHere.length > 0 ? 'predecessor_unfinished'
|
|
133
|
+
: connectionsOpen ? 'connection_open'
|
|
134
|
+
: !predecessorsDone ? 'predecessor_unfinished'
|
|
135
|
+
: !predecessorPhasesReady ? 'acceptance_edge' : null;
|
|
113
136
|
const blockingPhases = !phaseAcceptReady ? unacceptedEdges
|
|
114
137
|
: unreadyPhases.map((node) => ({ plan_key: node.plan_key, phase_id: node.phase_id, status: node.phase_status }));
|
|
138
|
+
const blockingConnections = openConnections.map(blockingConnection);
|
|
115
139
|
return {
|
|
116
140
|
taskDependenciesDone,
|
|
117
141
|
phaseAcceptReady,
|
|
118
142
|
dependenciesDone: taskDependenciesDone && phaseAcceptReady,
|
|
143
|
+
// start only: a schedule 接続 never gates done, and an in-progress task keeps its state when one is added.
|
|
144
|
+
startReady: taskDependenciesDone && phaseAcceptReady && !scheduleOpen,
|
|
145
|
+
scheduleOpen,
|
|
119
146
|
cause,
|
|
120
147
|
// a12: a refusal names what blocks, not only why.
|
|
121
148
|
blocking: cause === 'predecessor_unfinished'
|
|
122
|
-
? { blocking_tasks:
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
? { blocking_tasks: unfinishedHere.map(blockingTask).sort(byRef),
|
|
150
|
+
...(blockingConnections.length === 0 ? {} : { blocking_connections: blockingConnections }) }
|
|
151
|
+
: cause === 'connection_open' ? { blocking_connections: blockingConnections }
|
|
152
|
+
: cause === 'acceptance_edge'
|
|
153
|
+
? { blocking_phases: uniqueRefs(blockingPhases).map((phase) => ({ ...phase })).sort(byRef) } : {},
|
|
125
154
|
};
|
|
126
155
|
}
|
|
127
156
|
|
|
@@ -168,8 +197,10 @@ export function createTodoReadiness(store) {
|
|
|
168
197
|
prerequisiteRefs,
|
|
169
198
|
ownPhaseReady,
|
|
170
199
|
ownPhaseStatus,
|
|
200
|
+
connections,
|
|
201
|
+
allConnections,
|
|
171
202
|
isReady: (key) => nodes.get(key)?.status === 'pending'
|
|
172
|
-
&& ownPhaseReady(key) && prerequisites(key).
|
|
203
|
+
&& ownPhaseReady(key) && prerequisites(key).startReady,
|
|
173
204
|
startedSuccessor,
|
|
174
205
|
startedSuccessors,
|
|
175
206
|
phaseHasStartedSuccessor: (member, phaseId) => member.plan.schema === 'lattice.todo_plan.v4'
|
|
@@ -193,6 +224,21 @@ function blockingTask({ project_id: projectId, plan_key, task_id, status, reason
|
|
|
193
224
|
return projectId === undefined ? { plan_key, task_id, status }
|
|
194
225
|
: { project_id: projectId, plan_key, task_id, status, reason: reason ?? null };
|
|
195
226
|
}
|
|
227
|
+
/** The refusal entry for an open 接続: what it connects to, why, and since when (+ why a task target is unread). */
|
|
228
|
+
function blockingConnection({ kind, ref, reason, since, state_reason: stateReason }) {
|
|
229
|
+
return { kind, ref, reason, since, ...(stateReason === undefined ? {} : { state_reason: stateReason }) };
|
|
230
|
+
}
|
|
231
|
+
/** The read-contract `connections` of one task (他条件に接続 open and settled, plus 優先接続 when `store.priority_waits` is loaded), for `todo show` and the CLI (call withTodoExternalTasks first). */
|
|
232
|
+
export function listTodoConnections(store, planKey, taskId, { includeRemoved = false } = {}) {
|
|
233
|
+
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
234
|
+
if (member === undefined) return [];
|
|
235
|
+
const listed = createTodoReadiness(store).allConnections(`${member.plan.project_id}\0${planKey}\0${taskId}`);
|
|
236
|
+
if (!includeRemoved) return listed;
|
|
237
|
+
// A removed entry is history; a retry of remove needs it to answer `unchanged` rather than not-found.
|
|
238
|
+
const removed = projectTodoScheduleConnections(member.plan_scoped?.events).filter((entry) => entry.state === 'removed'
|
|
239
|
+
&& entry.task_id === taskId).map(({ task_id: _task, actor: _actor, provenance: _provenance, ended: _ended, ...shown }) => shown);
|
|
240
|
+
return [...listed, ...removed];
|
|
241
|
+
}
|
|
196
242
|
function byRef(left, right) {
|
|
197
243
|
return refId(left) < refId(right) ? -1 : refId(left) > refId(right) ? 1 : 0;
|
|
198
244
|
}
|
|
@@ -213,7 +259,7 @@ export function validateProspectiveEvent({ store, member, event }) {
|
|
|
213
259
|
const authoredStart = event.kind === 'start' && event.payload.start_mode !== 'historical_import'
|
|
214
260
|
&& event.payload.start_mode !== 'rebind';
|
|
215
261
|
if (authoredStart && (!prerequisites.phaseAcceptReady
|
|
216
|
-
|| (!prerequisites.taskDependenciesDone && event.payload.override_reason === null))) {
|
|
262
|
+
|| ((!prerequisites.taskDependenciesDone || prerequisites.scheduleOpen) && event.payload.override_reason === null))) {
|
|
217
263
|
return refused('invalid_start_transition', prerequisites.cause, prerequisites.blocking);
|
|
218
264
|
}
|
|
219
265
|
if (event.kind === 'done' && event.payload.done_mode === 'authored' && !prerequisites.dependenciesDone) {
|