@quolu/lattice 0.81.0 → 0.83.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/bin/lattice-bridge-supervisor.mjs +18 -3
- package/bin/lattice-dashboard.mjs +3 -18
- package/bin/lattice-mcp.mjs +6 -3
- package/bin/lattice.mjs +29 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +375 -0
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +35 -0
- package/package.json +4 -2
- package/sensor/dist/db/index.d.ts +1 -0
- package/sensor/dist/db/index.d.ts.map +1 -1
- package/sensor/dist/db/index.js +13 -0
- package/sensor/dist/db/index.js.map +1 -1
- package/sensor/dist/index.d.ts.map +1 -1
- package/sensor/dist/index.js +12 -2
- package/sensor/dist/index.js.map +1 -1
- package/sensor/dist/mcp/answer-freshness.js +1 -1
- package/sensor/dist/mcp/answer-freshness.js.map +1 -1
- package/sensor/dist/mcp/engine.d.ts +11 -0
- package/sensor/dist/mcp/engine.d.ts.map +1 -1
- package/sensor/dist/mcp/engine.js +83 -4
- package/sensor/dist/mcp/engine.js.map +1 -1
- package/sensor/dist/mcp/index-repair.d.ts +7 -0
- package/sensor/dist/mcp/index-repair.d.ts.map +1 -0
- package/sensor/dist/mcp/index-repair.js +93 -0
- package/sensor/dist/mcp/index-repair.js.map +1 -0
- package/sensor/dist/mcp/index.d.ts.map +1 -1
- package/sensor/dist/mcp/index.js +12 -7
- package/sensor/dist/mcp/index.js.map +1 -1
- package/sensor/dist/mcp/tools.d.ts +4 -0
- package/sensor/dist/mcp/tools.d.ts.map +1 -1
- package/sensor/dist/mcp/tools.js +29 -9
- package/sensor/dist/mcp/tools.js.map +1 -1
- package/src/bridge-cli.mjs +16 -4
- package/src/bridge-detached-supervisor.mjs +204 -0
- package/src/bridge-hub-server.mjs +46 -9
- package/src/bridge-startup-folder.mjs +7 -4
- package/src/cli-help.mjs +5 -2
- package/src/dashboard-lifecycle-journal.mjs +42 -20
- package/src/plan-backchain.mjs +31 -12
- package/src/plan-binding-carry.mjs +60 -0
- package/src/plan-revise.mjs +276 -0
- package/src/project-cli.mjs +50 -22
- package/src/project-identity.mjs +14 -0
- package/src/runtime-cli.mjs +31 -18
- package/src/runtime-control-store.mjs +22 -1
- package/src/runtime-decision-verifier.mjs +27 -8
- package/src/runtime-engine.mjs +34 -5
- package/src/runtime-hold-recompile.mjs +19 -15
- package/src/runtime-kept-worktree.mjs +136 -0
- package/src/runtime-lifecycle-lock.mjs +118 -30
- package/src/runtime-managed-supervisor.mjs +10 -10
- package/src/runtime-os-observation.mjs +39 -1
- package/src/runtime-pull-intake.mjs +87 -43
- package/src/store-lock.mjs +146 -59
- package/src/todo-authoring-input.mjs +57 -2
- package/src/todo-cli.mjs +173 -45
- package/src/todo-contracts.mjs +22 -6
- package/src/todo-dashboard-registry.mjs +31 -4
- package/src/todo-gantt-display.mjs +260 -0
- package/src/todo-gantt-html-independence.mjs +8 -1
- package/src/todo-gantt-html-shared.mjs +2 -1
- package/src/todo-gantt-html.mjs +4 -2
- package/src/todo-gantt-layout.mjs +7 -36
- package/src/todo-gantt-live.mjs +6 -3
- package/src/todo-note-store.mjs +13 -5
- package/src/todo-readiness.mjs +29 -8
- package/src/todo-revision.mjs +9 -8
- package/src/todo-split.mjs +6 -3
- package/src/todo-status.mjs +53 -9
- package/src/todo-store-cache.mjs +1 -1
- package/src/todo-store-view.mjs +21 -2
- package/src/todo-store.mjs +642 -172
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-side rendering states for the gantt serving paths
|
|
3
|
+
* (docs/architecture/dfd-display-gantt-read.md). A read-only view writes nothing,
|
|
4
|
+
* so a Store inconsistency is shown as a typed state instead of refused as a 500.
|
|
5
|
+
* Store owns the read, the checkpoint and the typed result; this module owns the
|
|
6
|
+
* tolerant projection, the banner/empty-state markup and the per-project memo.
|
|
7
|
+
*/
|
|
8
|
+
import { readTodoStoreDisplaySource, readTodoStoreForDisplay } from './todo-store.mjs';
|
|
9
|
+
import { digestTodoArtifact } from './todo-contracts.mjs';
|
|
10
|
+
import { escapeHtmlText } from './todo-gantt-html-shared.mjs';
|
|
11
|
+
|
|
12
|
+
export const GANTT_DISPLAY_REVALIDATE_MS = 30_000;
|
|
13
|
+
export const GANTT_DISPLAY_OMITTED_OVERLAYS = Object.freeze([
|
|
14
|
+
'presentation', 'independence frontier', 'seam proposals', 'notes', 'structures', 'narratives',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const TASK_STATUSES = ['pending', 'in-progress', 'blocked', 'retired', 'done'];
|
|
18
|
+
const PHASE_STATUSES = ['locked', 'active', 'gate_ready', 'reviewing', 'accepted', 'rejected',
|
|
19
|
+
'closed_unaudited'];
|
|
20
|
+
const CODE = /^[A-Z][A-Z0-9_]{0,63}$/u;
|
|
21
|
+
const SLUG = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,79}$/u;
|
|
22
|
+
|
|
23
|
+
const plain = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
24
|
+
const text = (value) => (typeof value === 'string' && value.length > 0 ? value : null);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Raw `{project_id, manifest, members:[{descriptor, plan, snapshot}]}` -> the renderer's
|
|
28
|
+
* read model. Task states and phase states come from the snapshot; titles, lanes, phases
|
|
29
|
+
* and dependency edges from `plan` when the Store could read it (`plan:null` falls back to
|
|
30
|
+
* ids in one lane without edges). Whatever cannot be projected is dropped and named; this
|
|
31
|
+
* never throws, and no edge that would make the layout fail (unknown endpoint, self edge,
|
|
32
|
+
* cycle) is kept.
|
|
33
|
+
*/
|
|
34
|
+
export function projectUnverifiedStore(raw) {
|
|
35
|
+
const dropped = [];
|
|
36
|
+
const members = [];
|
|
37
|
+
const projectId = text(raw?.project_id) ?? text(raw?.manifest?.project_id) ?? 'unknown';
|
|
38
|
+
const taskKey = (planKey, taskId) => JSON.stringify([planKey, taskId]);
|
|
39
|
+
const known = new Set();
|
|
40
|
+
const edgesOf = []; // {planKey, from, to, kind}
|
|
41
|
+
const refKeyOf = (ref) => (plain(ref) && ref.project_id === projectId && text(ref.plan_key) !== null
|
|
42
|
+
&& text(ref.task_id) !== null ? taskKey(ref.plan_key, ref.task_id) : null);
|
|
43
|
+
for (const entry of Array.isArray(raw?.members) ? raw.members : []) {
|
|
44
|
+
const planKey = text(entry?.descriptor?.plan_key);
|
|
45
|
+
const drop = (reason, extra = {}) => dropped.push({ plan_key: planKey,
|
|
46
|
+
code: 'DISPLAY_PROJECTION_DROPPED', reason, ...extra });
|
|
47
|
+
try {
|
|
48
|
+
if (planKey === null) { drop('descriptor_plan_key_invalid'); continue; }
|
|
49
|
+
const snapshot = entry.snapshot;
|
|
50
|
+
if (!plain(snapshot) || !Array.isArray(snapshot.tasks)) { drop('snapshot_tasks_invalid'); continue; }
|
|
51
|
+
const states = new Map();
|
|
52
|
+
for (const task of snapshot.tasks) {
|
|
53
|
+
const taskId = text(task?.task_id);
|
|
54
|
+
if (taskId === null || !TASK_STATUSES.includes(task.status)) {
|
|
55
|
+
drop('task_invalid', { task_id: taskId }); continue;
|
|
56
|
+
}
|
|
57
|
+
if (states.has(taskId)) { drop('task_duplicate', { task_id: taskId }); continue; }
|
|
58
|
+
states.set(taskId, { task_id: taskId, status: task.status, started_at: text(task.started_at),
|
|
59
|
+
done_at: text(task.done_at), blocked_reason: text(task.blocked_reason), evidence: null,
|
|
60
|
+
evidence_unverified: false, imported: false, test_result: null });
|
|
61
|
+
}
|
|
62
|
+
const plan = plain(entry.plan) && Array.isArray(entry.plan.tasks) ? entry.plan : null;
|
|
63
|
+
const planTasks = new Map();
|
|
64
|
+
for (const task of plan?.tasks ?? []) {
|
|
65
|
+
const taskId = text(task?.task_id);
|
|
66
|
+
if (taskId === null || planTasks.has(taskId)) { drop('plan_task_invalid', { task_id: taskId }); continue; }
|
|
67
|
+
if (!states.has(taskId)) { drop('task_state_missing', { task_id: taskId }); continue; }
|
|
68
|
+
planTasks.set(taskId, { task_id: taskId, title: text(task.title) ?? taskId,
|
|
69
|
+
lane: text(task.lane) ?? 'unverified', narrative_ref: null,
|
|
70
|
+
...(text(task.phase_id) === null ? {} : { phase_id: task.phase_id }) });
|
|
71
|
+
}
|
|
72
|
+
// snapshot states the plan does not name still show, by id
|
|
73
|
+
for (const taskId of states.keys()) {
|
|
74
|
+
if (!planTasks.has(taskId)) planTasks.set(taskId, { task_id: taskId, title: taskId,
|
|
75
|
+
lane: 'unverified', narrative_ref: null });
|
|
76
|
+
}
|
|
77
|
+
if (planTasks.size === 0) { drop('no_projectable_task'); continue; }
|
|
78
|
+
const phases = [];
|
|
79
|
+
for (const phase of Array.isArray(snapshot.phases) ? snapshot.phases : []) {
|
|
80
|
+
const phaseId = text(phase?.phase_id);
|
|
81
|
+
if (phaseId === null || !PHASE_STATUSES.includes(phase.status)) {
|
|
82
|
+
drop('phase_invalid', { phase_id: phaseId }); continue;
|
|
83
|
+
}
|
|
84
|
+
phases.push({ phase_id: phaseId, status: phase.status, review_event_digest: null,
|
|
85
|
+
decision_event_digest: null, decision_evidence: null });
|
|
86
|
+
}
|
|
87
|
+
const phaseMeta = [];
|
|
88
|
+
for (const phase of Array.isArray(plan?.phases) ? plan.phases : []) {
|
|
89
|
+
const phaseId = text(phase?.phase_id);
|
|
90
|
+
if (phaseId === null) { drop('plan_phase_invalid'); continue; }
|
|
91
|
+
phaseMeta.push({ phase_id: phaseId, title: text(phase.title) ?? phaseId,
|
|
92
|
+
gate_policy: text(phase.gate_policy) ?? 'heavy' });
|
|
93
|
+
}
|
|
94
|
+
for (const taskId of planTasks.keys()) known.add(taskKey(planKey, taskId));
|
|
95
|
+
for (const edge of Array.isArray(plan?.hard_dependencies) ? plan.hard_dependencies : []) {
|
|
96
|
+
edgesOf.push({ planKey, kind: 'hard', from: edge?.from, to: edge?.to });
|
|
97
|
+
}
|
|
98
|
+
for (const join of Array.isArray(plan?.joins) ? plan.joins : []) {
|
|
99
|
+
edgesOf.push({ planKey, kind: 'join', join, from: join?.after, to: join?.before });
|
|
100
|
+
}
|
|
101
|
+
const descriptor = entry.descriptor;
|
|
102
|
+
members.push({
|
|
103
|
+
descriptor: { plan_key: planKey, active_plan_version: text(descriptor.active_plan_version),
|
|
104
|
+
topology_digest: text(descriptor.topology_digest) },
|
|
105
|
+
plan: { schema: 'lattice.todo_plan.v1', project_id: projectId, plan_key: planKey,
|
|
106
|
+
plan_version: text(snapshot.plan_version) ?? text(descriptor.active_plan_version) ?? 'unknown',
|
|
107
|
+
topology_digest: text(descriptor.topology_digest), hard_dependencies: [], joins: [],
|
|
108
|
+
phases: phaseMeta, tasks: [...planTasks.values()] },
|
|
109
|
+
tasks: [...planTasks.keys()].map((taskId) => states.get(taskId)), phases,
|
|
110
|
+
journal: { events: [] }, plan_scoped: { events: [] }, revision: null,
|
|
111
|
+
coordination: null, snapshot_stale: false,
|
|
112
|
+
});
|
|
113
|
+
} catch {
|
|
114
|
+
drop('projection_failed');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Edges last: an endpoint must be a projected task, and no edge may close a cycle.
|
|
118
|
+
const successors = new Map();
|
|
119
|
+
const reaches = (from, to, seen = new Set()) => {
|
|
120
|
+
if (from === to) return true;
|
|
121
|
+
if (seen.has(from)) return false;
|
|
122
|
+
seen.add(from);
|
|
123
|
+
return (successors.get(from) ?? []).some((next) => reaches(next, to, seen));
|
|
124
|
+
};
|
|
125
|
+
const byPlan = new Map(members.map((member) => [member.plan.plan_key, member.plan]));
|
|
126
|
+
for (const { planKey, kind, join, from, to } of edgesOf) {
|
|
127
|
+
const targetKey = refKeyOf(to);
|
|
128
|
+
const sources = (kind === 'join' ? (Array.isArray(from) ? from : [null]) : [from]).map(refKeyOf);
|
|
129
|
+
const refOf = (ref) => ({ project_id: ref.project_id, plan_key: ref.plan_key, task_id: ref.task_id });
|
|
130
|
+
const valid = targetKey !== null && known.has(targetKey)
|
|
131
|
+
&& sources.every((key) => key !== null && known.has(key) && key !== targetKey)
|
|
132
|
+
&& (kind !== 'join' || text(join?.id) !== null);
|
|
133
|
+
// a join with any bad endpoint is dropped whole; a cycle drops only the closing edge
|
|
134
|
+
if (!valid || sources.some((key) => reaches(targetKey, key))) {
|
|
135
|
+
dropped.push({ plan_key: planKey, code: 'DISPLAY_PROJECTION_DROPPED',
|
|
136
|
+
reason: kind === 'join' ? 'join_invalid' : 'dependency_invalid', task_id: text(to?.task_id) });
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
for (const key of sources) successors.set(key, [...(successors.get(key) ?? []), targetKey]);
|
|
140
|
+
const plan = byPlan.get(planKey);
|
|
141
|
+
if (kind === 'hard') plan.hard_dependencies.push({ from: refOf(from), to: refOf(to) });
|
|
142
|
+
else plan.joins.push({ id: join.id, after: from.map(refOf), before: refOf(to) });
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
store: { schema: 'lattice.todo_store_read.v1', project_id: projectId,
|
|
146
|
+
manifest: { manifest_digest: text(raw?.manifest?.manifest_digest) }, members,
|
|
147
|
+
snapshot_stale: false },
|
|
148
|
+
dropped,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Only these two slugs of an inconsistency leave the server; everything else in `detail` stays.
|
|
153
|
+
export function publicDiagnostic(inconsistency) {
|
|
154
|
+
const code = CODE.test(inconsistency?.code) ? inconsistency.code : '-';
|
|
155
|
+
const reason = SLUG.test(inconsistency?.detail?.reason) ? inconsistency.detail.reason : '-';
|
|
156
|
+
return { code, reason };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const BANNER_STYLE = 'margin:0;padding:10px 16px;border-bottom:2px solid #e85f2a;background:#fff4e8;color:#201d19;font:13px/1.6 system-ui,-apple-system,"Hiragino Sans","Yu Gothic UI",sans-serif';
|
|
160
|
+
|
|
161
|
+
function droppedMarkup(dropped) {
|
|
162
|
+
if (dropped.length === 0) return '';
|
|
163
|
+
const items = dropped.map((entry) => `<li><code>${escapeHtmlText(entry.plan_key ?? '-')}</code>${entry.task_id ? ` / <code>${escapeHtmlText(entry.task_id)}</code>` : ''}${entry.phase_id ? ` / <code>${escapeHtmlText(entry.phase_id)}</code>` : ''}: <code>${escapeHtmlText(CODE.test(entry.code) ? entry.code : 'DISPLAY_DROPPED')}</code> / <code>${escapeHtmlText(SLUG.test(entry.reason) ? entry.reason : '-')}</code></li>`).join('');
|
|
164
|
+
return `<p>表示から除いた対象:</p><ul>${items}</ul>`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function omittedMarkup() {
|
|
168
|
+
return `<p>表示していない情報: ${GANTT_DISPLAY_OMITTED_OVERLAYS.map((name) => `<code>${escapeHtmlText(name)}</code>`).join(' · ')}</p>`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** `dropped` = Store dropped_members plus projection drops. Never claims validation. */
|
|
172
|
+
export function degradedBannerHtml({ state, verifiedAt = null, inconsistency, dropped = [] }) {
|
|
173
|
+
const { code, reason } = publicDiagnostic(inconsistency);
|
|
174
|
+
const lead = state === 'last_verified'
|
|
175
|
+
? `最後に確認できた状態(${escapeHtmlText(verifiedAt ?? '-')})を表示中。現在の計画は整合していない`
|
|
176
|
+
: '未検証の現在の状態を表示中。計画は整合していない';
|
|
177
|
+
return `<aside role="status" data-display-state="${escapeHtmlText(state)}" style="${BANNER_STYLE}"><strong>${lead}: <code>${escapeHtmlText(code)}</code> / <code>${escapeHtmlText(reason)}</code></strong>${omittedMarkup()}${droppedMarkup(dropped)}</aside>`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** HTTP 200 page for `unavailable` (and an unverified view with nothing projectable). */
|
|
181
|
+
export function emptyStateHtml({ inconsistency, dropped = [] }) {
|
|
182
|
+
const { code, reason } = publicDiagnostic(inconsistency);
|
|
183
|
+
return `<!doctype html><html lang="ja"><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lattice — 表示できる工程がありません</title></head><body><main data-display-state="unavailable" style="max-width:720px;margin:48px auto;padding:0 16px;font:16px/1.7 system-ui,-apple-system,'Hiragino Sans','Yu Gothic UI',sans-serif;color:#201d19"><h1>表示できる工程データがありません</h1><p>計画の状態を読み取れませんでした: <code>${escapeHtmlText(code)}</code> / <code>${escapeHtmlText(reason)}</code></p><p>読み取れるようになると、このページは自動で更新されます。</p>${droppedMarkup(dropped)}</main></body></html>`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Live head: source + state + inconsistency code; overlay digests only when verified. */
|
|
187
|
+
export function displayHeadDigest(result, overlayHead = null) {
|
|
188
|
+
return digestTodoArtifact({
|
|
189
|
+
schema: 'lattice.todo_gantt_display_head.v1',
|
|
190
|
+
state: result.state,
|
|
191
|
+
source: result.source ?? null,
|
|
192
|
+
inconsistency_code: result.inconsistency?.code ?? null,
|
|
193
|
+
overlay_head: result.state === 'verified' ? overlayHead : null,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const PROJECT_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;
|
|
198
|
+
|
|
199
|
+
/** Project id and plan keys a display result carries; unavailable carries neither. */
|
|
200
|
+
export function displayResultBinding(result) {
|
|
201
|
+
let projectId = null;
|
|
202
|
+
let planKeys = [];
|
|
203
|
+
if (result.state === 'unverified') {
|
|
204
|
+
const { store } = projectUnverifiedStore(result.store);
|
|
205
|
+
projectId = text(result.store?.project_id) ?? text(result.store?.manifest?.project_id);
|
|
206
|
+
planKeys = store.members.map(({ plan }) => plan.plan_key);
|
|
207
|
+
} else if (result.state === 'verified' || result.state === 'last_verified') {
|
|
208
|
+
projectId = text(result.store?.project_id);
|
|
209
|
+
planKeys = (Array.isArray(result.store?.members) ? result.store.members : [])
|
|
210
|
+
.map((member) => member?.descriptor?.plan_key).filter((key) => typeof key === 'string');
|
|
211
|
+
}
|
|
212
|
+
return { projectId: PROJECT_ID.test(projectId) ? projectId : null, planKeys: planKeys.sort() };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* One per project, shared by every client. The memo is keyed by the source token
|
|
217
|
+
* observed at the last full-read attempt (not result.source, which is the
|
|
218
|
+
* checkpoint's in last_verified and null in unavailable), so a degraded but
|
|
219
|
+
* unchanged store is not fully re-read every poll. A probe failure is its own key:
|
|
220
|
+
* one full read, then reuse until the revalidation ceiling.
|
|
221
|
+
*/
|
|
222
|
+
export function createTodoGanttDisplayReader({
|
|
223
|
+
repoRoot, readForDisplay = readTodoStoreForDisplay, readDisplaySource = readTodoStoreDisplaySource,
|
|
224
|
+
revalidateMs = GANTT_DISPLAY_REVALIDATE_MS, now = Date.now,
|
|
225
|
+
}) {
|
|
226
|
+
let memo = null;
|
|
227
|
+
let inflight = null;
|
|
228
|
+
const observe = async () => {
|
|
229
|
+
try { return `ok:${digestTodoArtifact(await readDisplaySource({ repoRoot }))}`; }
|
|
230
|
+
catch (error) { return `fail:${error?.code ?? 'PROBE_FAILED'}`; }
|
|
231
|
+
};
|
|
232
|
+
const load = async () => {
|
|
233
|
+
const key = await observe();
|
|
234
|
+
if (memo !== null && memo.valid && memo.key === key && now() - memo.at < revalidateMs) {
|
|
235
|
+
if (memo.fault !== undefined) throw memo.fault;
|
|
236
|
+
return memo.result;
|
|
237
|
+
}
|
|
238
|
+
const at = now();
|
|
239
|
+
memo = null;
|
|
240
|
+
// A token change during the attempt leaves the memo invalid for the next poll.
|
|
241
|
+
const settle = async (outcome) => {
|
|
242
|
+
memo = { key, at, valid: (await observe()) === key, ...outcome };
|
|
243
|
+
};
|
|
244
|
+
let result;
|
|
245
|
+
try { result = await readForDisplay({ repoRoot }); } catch (fault) {
|
|
246
|
+
// A real fault (not a typed result) is bounded like a probe failure: an unchanged token
|
|
247
|
+
// with a persisting fault is not re-read every poll; the revalidation ceiling still applies.
|
|
248
|
+
await settle({ fault });
|
|
249
|
+
throw fault;
|
|
250
|
+
}
|
|
251
|
+
await settle({ result });
|
|
252
|
+
return result;
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
read() {
|
|
256
|
+
inflight ??= load().finally(() => { inflight = null; });
|
|
257
|
+
return inflight;
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
@@ -69,6 +69,13 @@ function renderDesignMemo(task) {
|
|
|
69
69
|
return `<section class="design-memo"><h2>設計メモ</h2><div class="design-memo-body">${rendered.html}</div>${filtering}</section>`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** 作成者が書いた終了条件(u12)。プレーンテキストをescapeして出し、文字列でなければ何も出さない。 */
|
|
73
|
+
function renderDoneCondition(task) {
|
|
74
|
+
if (typeof task.done_condition !== 'string') return '';
|
|
75
|
+
const text = escapeHtmlText(task.done_condition).replace(/\r\n|\r|\n/gu, '<br>');
|
|
76
|
+
return `<section><h2>終了条件</h2><p class="done-condition-body">${text}</p></section>`;
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
/**
|
|
73
80
|
* 図の外が語るための独立性要約を、plan単位の投影から引ける形へ畳む(ADR 0129 Decision 3)。
|
|
74
81
|
*/
|
|
@@ -246,7 +253,7 @@ export function renderRightPane(
|
|
|
246
253
|
? '<p class="fold-note">完走済みのため既定の図には描いていません。左上の「完走済み」バッジを押すと、このページ内で表示できます。</p>'
|
|
247
254
|
: '<p class="fold-note">完走済みのため図には描いていません。図に出すには動的dashboardを <code>lattice todo gantt serve --port <port> --scope all</code> で起動してください。</p>';
|
|
248
255
|
const workLog = notesEnabled ? renderNoteContext(section.noteContext, hostDisplayNames) : '';
|
|
249
|
-
const designMemo = renderDesignMemo(section.task);
|
|
256
|
+
const designMemo = renderDesignMemo(section.task) + renderDoneCondition(section.task);
|
|
250
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>`;
|
|
251
258
|
}).join('');
|
|
252
259
|
const taskIndex = renderTaskIndex(sections, lookup, folds, planActivity(readModel));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderTodoGanttSvg, TODO_GANTT_STATUS_PRESENTATION } from './todo-gantt-svg.mjs';
|
|
2
|
+
import { isDecoupledPhaseTodoPlanSchema } from './todo-store-view.mjs';
|
|
2
3
|
|
|
3
4
|
export const DOCUMENT_STATUS = TODO_GANTT_STATUS_PRESENTATION;
|
|
4
5
|
|
|
@@ -158,7 +159,7 @@ export function renderPhaseProgress(readModel) {
|
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
const decoupled = readModel.members.some(({ plan }) => (
|
|
161
|
-
|
|
162
|
+
isDecoupledPhaseTodoPlanSchema(plan.schema)
|
|
162
163
|
));
|
|
163
164
|
const guidance = decoupled
|
|
164
165
|
? 'ToDo完了とPhase受理は別です。Phaseは重監査の順序を表し、通常ToDoの開始順はToDo依存だけで決まります。'
|
package/src/todo-gantt-html.mjs
CHANGED
|
@@ -87,8 +87,10 @@ function normalizeSections(readModel, narratives, anchorOutcomes, noteContexts)
|
|
|
87
87
|
const narrative = supplied.get(refKey(ref));
|
|
88
88
|
const markdown = narrative?.markdown ?? '';
|
|
89
89
|
const narrativeRef = narrative?.narrative_ref ?? task.narrative_ref;
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// 終了条件(u12)も設計メモと同じ埋め込み散文として数える。
|
|
91
|
+
for (const prose of [task.design_memo, task.done_condition]) {
|
|
92
|
+
if (typeof prose !== 'string') continue;
|
|
93
|
+
proseBytes += Buffer.byteLength(prose, 'utf8');
|
|
92
94
|
if (proseBytes > TODO_GANTT_PROSE_MAX_BYTES) {
|
|
93
95
|
throw new TodoGanttRenderError('TODO_SCALE_EXCEEDED', 'todo gantt embedded prose limit exceeded', {
|
|
94
96
|
prose_bytes: proseBytes, prose_limit: TODO_GANTT_PROSE_MAX_BYTES,
|
|
@@ -2,6 +2,7 @@ import { TODO_GANTT_SCOPES, projectTodoGanttScope } from './todo-gantt-scope.mjs
|
|
|
2
2
|
import { buildTodoGanttHierarchy } from './todo-gantt-nested.mjs';
|
|
3
3
|
import { projectTodoCrossPlanDependencies } from './todo-store.mjs';
|
|
4
4
|
import { projectTodoChainV1 } from './todo-chain.mjs';
|
|
5
|
+
import { createTodoReadiness } from './todo-readiness.mjs';
|
|
5
6
|
|
|
6
7
|
const TASK_LIMIT = 2_000;
|
|
7
8
|
const EDGE_LIMIT = 8_000;
|
|
@@ -247,41 +248,11 @@ function normalizeInput(readModel) {
|
|
|
247
248
|
return { nodes, nodesByKey, edges, retiredKeys };
|
|
248
249
|
}
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
for (const phase of member.phases ?? []) {
|
|
256
|
-
phaseStatuses.set(JSON.stringify([
|
|
257
|
-
member.plan.project_id, member.plan.plan_key, phase.phase_id,
|
|
258
|
-
]), phase.status);
|
|
259
|
-
}
|
|
260
|
-
if (['lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(member.plan.schema)) {
|
|
261
|
-
for (const edge of member.plan.phase_accept_dependencies ?? []) {
|
|
262
|
-
const target = refKey(refOf(edge.to, 'phase_accept_dependencies.to'));
|
|
263
|
-
if (retiredKeys.has(target)) continue;
|
|
264
|
-
if (!nodesByKey.has(target)) {
|
|
265
|
-
fail('TODO_LAYOUT_INVALID_INPUT', 'phase accept dependency targets an absent task');
|
|
266
|
-
}
|
|
267
|
-
phaseAcceptIncoming.get(target).add(JSON.stringify([
|
|
268
|
-
edge.from.project_id, edge.from.plan_key, edge.from.phase_id,
|
|
269
|
-
]));
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return new Set(nodes.filter((node) => node.status === 'pending' && node.phase_ready
|
|
274
|
-
&& incoming.get(node.key).every((predecessorKey) => {
|
|
275
|
-
const predecessor = nodesByKey.get(predecessorKey);
|
|
276
|
-
return predecessor.status === 'done'
|
|
277
|
-
&& (predecessor.plan_schema !== 'lattice.todo_plan.v4'
|
|
278
|
-
|| predecessor.phase_id === null
|
|
279
|
-
|| (predecessor.ref.plan_key === node.ref.plan_key
|
|
280
|
-
&& predecessor.phase_id === node.phase_id)
|
|
281
|
-
|| predecessor.phase_status === 'accepted');
|
|
282
|
-
}) && [...phaseAcceptIncoming.get(node.key)]
|
|
283
|
-
.every((phaseKey) => phaseStatuses.get(phaseKey) === 'accepted'))
|
|
284
|
-
.map(({ key }) => key));
|
|
251
|
+
// u03 D-gantt: the drawing never decides readiness itself. Lattice's readiness (the same one
|
|
252
|
+
// status and start use) decides, so a successor of a retired-not-done task is not drawn ready.
|
|
253
|
+
function readyTaskKeys(readModel, nodes) {
|
|
254
|
+
const readiness = createTodoReadiness(readModel);
|
|
255
|
+
return new Set(nodes.filter((node) => readiness.isReady(readiness.key(node.ref))).map(({ key }) => key));
|
|
285
256
|
}
|
|
286
257
|
|
|
287
258
|
function assignWaves(nodes, nodesByKey, edges) {
|
|
@@ -547,7 +518,7 @@ function layoutTodoGanttFlat(readModel, options = {}) {
|
|
|
547
518
|
});
|
|
548
519
|
const longestNodeKeys = new Set(chain.longest_chain_node_refs.map(refKey));
|
|
549
520
|
const longestEdgeKeys = new Set(chain.longest_chain_edges.map(edge => JSON.stringify([refKey(edge.from), refKey(edge.to)])));
|
|
550
|
-
const readyKeys = readyTaskKeys(readModel, full.nodes
|
|
521
|
+
const readyKeys = readyTaskKeys(readModel, full.nodes);
|
|
551
522
|
const independence = normalizeIndependence(options.independence ?? null, full.nodesByKey);
|
|
552
523
|
const seamProposals = normalizeSeamProposals(options.seamProposals ?? null);
|
|
553
524
|
|
package/src/todo-gantt-live.mjs
CHANGED
|
@@ -60,7 +60,7 @@ function withExternalPane(html, pane) {
|
|
|
60
60
|
).replace('</body>', `${externalPaneController(pane)}</body>`);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
function liveHtml(html, headDigest, eventsPath, externalPane = null) {
|
|
63
|
+
function liveHtml(html, headDigest, eventsPath, externalPane = null, bannerHtml = null) {
|
|
64
64
|
const controller = `<script>(()=>{const badge=document.createElement('div');badge.setAttribute('role','status');badge.style.cssText='position:fixed;right:12px;bottom:12px;z-index:99;padding:6px 10px;border:1px solid #d9d8d4;border-radius:4px;background:#fcfcfb;font:600 12px system-ui';badge.textContent='進捗: 接続中';document.body.append(badge);const head=${JSON.stringify(headDigest)};let lastReceipt=Date.now();let stream=null;const receive=event=>{const next=JSON.parse(event.data);if(typeof next.head_digest!=='string')return;lastReceipt=Date.now();badge.textContent='進捗: 最新';if(next.head_digest!==head){badge.textContent='進捗: 更新を反映中';location.reload();}};const connect=()=>{if(stream)stream.close();badge.textContent='進捗: 接続中';stream=new EventSource(${JSON.stringify(eventsPath)});stream.onopen=()=>{lastReceipt=Date.now();};stream.addEventListener('state',receive);stream.addEventListener('ping',receive);stream.addEventListener('lattice-error',event=>{lastReceipt=Date.now();const detail=JSON.parse(event.data);badge.textContent='進捗: エラー '+detail.code;badge.style.borderColor='#d03b3b';});stream.onerror=()=>{badge.textContent='進捗: 再接続中';};};connect();setInterval(()=>{if(Date.now()-lastReceipt>${SSE_STALE_MS})connect();},${SSE_WATCHDOG_MS});})();</script>`;
|
|
65
65
|
const publicMetadata = '<meta name="description" content="Latticeで管理しているプロジェクトの依存工程と進捗を確認できます。"><meta name="theme-color" content="#f7f3ea">';
|
|
66
66
|
const publicStyle = '<style>body[data-gantt-root]{grid-template-rows:auto minmax(0,1fr)}.lattice-live-brand{z-index:10;display:flex;align-items:center;gap:8px;min-width:0;padding:10px 16px;border-bottom:1px solid #d8d0c5;background:#f7f3ea;color:#6c655d;font:600 12px/1.5 system-ui,-apple-system,"Hiragino Sans","Yu Gothic UI",sans-serif}.lattice-live-brand a{color:#201d19;text-decoration:none}.lattice-live-brand a:hover{color:#315cbe}.lattice-live-brand strong{color:#201d19}.lattice-live-brand-note{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lattice-live-back{margin-left:auto!important;color:#315cbe!important;font-weight:750}@media(max-width:560px){.lattice-live-brand{padding:9px 12px}.lattice-live-brand-note{display:none}}</style>';
|
|
@@ -68,7 +68,9 @@ function liveHtml(html, headDigest, eventsPath, externalPane = null) {
|
|
|
68
68
|
const live = html
|
|
69
69
|
.replace("default-src 'none';", "default-src 'none'; connect-src 'self';")
|
|
70
70
|
.replace('</head>', `${publicMetadata}${publicStyle}</head>`)
|
|
71
|
-
.replace(/<body([^>]*)>/u, `<body$1>${publicHeader
|
|
71
|
+
.replace(/<body([^>]*)>/u, `<body$1>${bannerHtml === null ? publicHeader
|
|
72
|
+
// The banner shares the header's grid row so the page's row layout is unchanged.
|
|
73
|
+
: `<div>${publicHeader}${bannerHtml}</div>`}`)
|
|
72
74
|
.replace('</body>', `${controller}</body>`);
|
|
73
75
|
return externalPane === null ? live : withExternalPane(live, externalPane);
|
|
74
76
|
}
|
|
@@ -286,7 +288,8 @@ export async function startTodoGanttDashboardServer({
|
|
|
286
288
|
lastHeads.set(project.projectId, rendered.head_digest);
|
|
287
289
|
// 外部ペイン設定は描画のたびにrender側が読み直す。差した/外した側は再起動を要さない。
|
|
288
290
|
const html = liveHtml(rendered.html, rendered.head_digest,
|
|
289
|
-
`${projectPath(project.projectId)}events`, rendered.external_pane ?? null
|
|
291
|
+
`${projectPath(project.projectId)}events`, rendered.external_pane ?? null,
|
|
292
|
+
rendered.banner_html ?? null);
|
|
290
293
|
response.writeHead(200, { 'content-type': 'text/html; charset=utf-8',
|
|
291
294
|
'cache-control': 'no-store', 'x-content-type-options': 'nosniff' });
|
|
292
295
|
response.end(html);
|
package/src/todo-note-store.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
8
8
|
import { syncPublishedFile } from './fs-publish.mjs';
|
|
9
|
+
import { normalizeCheckoutEol } from './todo-store-view.mjs';
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
TODO_LIMITS,
|
|
@@ -88,7 +89,7 @@ async function readOptionalBounded(ref, { missing = false } = {}) {
|
|
|
88
89
|
if (!metadata.isFile() || metadata.size > TODO_LIMITS.journalSegmentBytes) {
|
|
89
90
|
fail('NOTE_LOG_CORRUPT', 'note_segment_invalid', { ref });
|
|
90
91
|
}
|
|
91
|
-
return await readFile(ref);
|
|
92
|
+
return normalizeCheckoutEol(await readFile(ref));
|
|
92
93
|
} catch (error) {
|
|
93
94
|
if (error instanceof TodoNoteStoreError) throw error;
|
|
94
95
|
if (missing && error?.code === 'ENOENT') return null;
|
|
@@ -263,7 +264,7 @@ export async function appendTodoNote(options = {}) {
|
|
|
263
264
|
const planScoped = options.taskId === null;
|
|
264
265
|
const scope = planScoped ? 'plan' : 'task';
|
|
265
266
|
const repoRoot = path.resolve(options.repoRoot);
|
|
266
|
-
return withNoteLock(repoRoot, async () => {
|
|
267
|
+
return withNoteLock(repoRoot, async (assertHeld) => {
|
|
267
268
|
// sequenceとprevious_digestはchainごとに独立。note系の起点は1(journal系の0ではない)。
|
|
268
269
|
const chain = await readTodoNoteEvents({ repoRoot, planKey: options.planKey, scope });
|
|
269
270
|
if (options.supersedes !== null) {
|
|
@@ -299,6 +300,8 @@ export async function appendTodoNote(options = {}) {
|
|
|
299
300
|
const paths = chainRefs(repoRoot, options.planKey, scope);
|
|
300
301
|
await ensureNoteDirectory(path.dirname(paths.active));
|
|
301
302
|
const eventBytes = canonicalLine(event);
|
|
303
|
+
// A holder that lost its lock while suspended must not overwrite the new owner's chain.
|
|
304
|
+
await assertHeld();
|
|
302
305
|
if (chain.active_bytes.length > 0
|
|
303
306
|
&& chain.active_bytes.length + eventBytes.length > TODO_LIMITS.journalSegmentBytes) {
|
|
304
307
|
const activeEvents = parseCanonicalSegment(chain.active_bytes, paths.active);
|
|
@@ -471,7 +474,7 @@ async function readCanonicalJson(ref, { missing = false } = {}) {
|
|
|
471
474
|
if (!metadata.isFile() || metadata.size > TODO_LIMITS.snapshotBytes) {
|
|
472
475
|
fail('NOTE_PROJECTION_INVALID', 'note_projection_artifact_invalid', { ref });
|
|
473
476
|
}
|
|
474
|
-
bytes = await readFile(ref);
|
|
477
|
+
bytes = normalizeCheckoutEol(await readFile(ref));
|
|
475
478
|
} catch (error) {
|
|
476
479
|
if (error instanceof TodoNoteStoreError) throw error;
|
|
477
480
|
if (missing && error?.code === 'ENOENT') return null;
|
|
@@ -621,9 +624,11 @@ export async function readTodoPlanNotesForStatus(options = {}) {
|
|
|
621
624
|
return summaries;
|
|
622
625
|
}
|
|
623
626
|
|
|
624
|
-
/**
|
|
627
|
+
/** 1 planを一度だけ読み全taskへ投影する。includeHistoryはbudget前の履歴も返す。 */
|
|
625
628
|
export async function readTodoNoteContextsForPlan(options = {}) {
|
|
626
|
-
|
|
629
|
+
const keys = ['repoRoot', 'store', 'planKey'];
|
|
630
|
+
if (!(exactRecord(options, keys) || exactRecord(options, [...keys, 'includeHistory']))
|
|
631
|
+
|| ('includeHistory' in options && typeof options.includeHistory !== 'boolean')
|
|
627
632
|
|| !isTodoIdentifier(options.planKey)
|
|
628
633
|
|| options.store === null || typeof options.store !== 'object') {
|
|
629
634
|
throw new TypeError('todo note contexts read options invalid');
|
|
@@ -654,5 +659,8 @@ export async function readTodoNoteContextsForPlan(options = {}) {
|
|
|
654
659
|
contexts: projected.map(({ context }) => context),
|
|
655
660
|
archived: projected[0]?.archived ?? [],
|
|
656
661
|
note_head_digest: chain.head_digest,
|
|
662
|
+
...(options.includeHistory ? { histories: projected.map(({ context, history }) => ({
|
|
663
|
+
task_id: context.task_id, history,
|
|
664
|
+
})) } : {}),
|
|
657
665
|
};
|
|
658
666
|
}
|
package/src/todo-readiness.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isDecoupledPhaseTodoPlanSchema,
|
|
3
|
+
isFinishedTodoTaskState,
|
|
3
4
|
isPhaseTodoPlanSchema,
|
|
4
5
|
projectTodoCrossPlanDependencies,
|
|
5
6
|
} from './todo-store-view.mjs';
|
|
7
|
+
import { TodoStoreError } from './todo-store.mjs';
|
|
6
8
|
|
|
7
9
|
function taskKey(ref) {
|
|
8
10
|
return `${ref.project_id}\0${ref.plan_key}\0${ref.task_id}`;
|
|
@@ -22,13 +24,15 @@ export function createTodoReadiness(store) {
|
|
|
22
24
|
const acceptanceOutgoing = new Map();
|
|
23
25
|
for (const member of store.members) {
|
|
24
26
|
const { plan } = member;
|
|
25
|
-
const states = new Map(member.tasks.map((state) => [state.task_id, state
|
|
27
|
+
const states = new Map(member.tasks.map((state) => [state.task_id, state]));
|
|
26
28
|
const phaseStates = new Map((member.phases ?? []).map((phase) => [phase.phase_id, phase.status]));
|
|
27
29
|
for (const phase of member.phases ?? []) phases.set(phaseKey({ ...plan, ...phase }), phase.status);
|
|
28
30
|
for (const task of plan.tasks) {
|
|
29
31
|
const key = taskKey({ ...plan, ...task });
|
|
30
32
|
nodes.set(key, {
|
|
31
|
-
status: states.get(task.task_id),
|
|
33
|
+
status: states.get(task.task_id)?.status,
|
|
34
|
+
// retired from doneも先行として完了扱い(u12)。判定はStore replayと同じ一つの述語。
|
|
35
|
+
finished: isFinishedTodoTaskState(states.get(task.task_id)),
|
|
32
36
|
schema: plan.schema,
|
|
33
37
|
plan_key: plan.plan_key,
|
|
34
38
|
phase_id: isPhaseTodoPlanSchema(plan.schema) ? task.phase_id : null,
|
|
@@ -46,12 +50,13 @@ export function createTodoReadiness(store) {
|
|
|
46
50
|
outgoing.get(source)?.add(target);
|
|
47
51
|
};
|
|
48
52
|
for (const member of store.members) {
|
|
49
|
-
|
|
50
|
-
for (const
|
|
53
|
+
// `?? []`: the display reads unverified members too and must not stop on a missing list (u01).
|
|
54
|
+
for (const edge of member.plan.hard_dependencies ?? []) connect(edge.from, edge.to);
|
|
55
|
+
for (const join of member.plan.joins ?? []) {
|
|
51
56
|
for (const after of join.after) connect(after, join.before);
|
|
52
57
|
}
|
|
53
58
|
if (isDecoupledPhaseTodoPlanSchema(member.plan.schema)) {
|
|
54
|
-
for (const edge of member.plan.phase_accept_dependencies) {
|
|
59
|
+
for (const edge of member.plan.phase_accept_dependencies ?? []) {
|
|
55
60
|
const source = phaseKey(edge.from);
|
|
56
61
|
const target = taskKey(edge.to);
|
|
57
62
|
acceptanceIncoming.get(target)?.add(source);
|
|
@@ -72,12 +77,14 @@ export function createTodoReadiness(store) {
|
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
function prerequisites(key) {
|
|
75
|
-
|
|
76
|
-
const
|
|
80
|
+
// u03 A24: 消えた端点(Storeのendpoint_missing finding)は後続を止めない。Store replayも同じ規則。
|
|
81
|
+
const predecessors = [...(incoming.get(key) ?? [])].map((source) => nodes.get(source))
|
|
82
|
+
.filter((node) => node !== undefined);
|
|
83
|
+
const predecessorsDone = predecessors.every((node) => node?.finished === true);
|
|
77
84
|
const predecessorPhasesReady = predecessors.every((node) => dependencyPhaseReady(node, nodes.get(key)));
|
|
78
85
|
const taskDependenciesDone = predecessorsDone && predecessorPhasesReady;
|
|
79
86
|
const phaseAcceptReady = [...(acceptanceIncoming.get(key) ?? [])]
|
|
80
|
-
.every((source) => phases.get(source) === 'accepted');
|
|
87
|
+
.every((source) => !phases.has(source) || phases.get(source) === 'accepted');
|
|
81
88
|
return {
|
|
82
89
|
taskDependenciesDone,
|
|
83
90
|
phaseAcceptReady,
|
|
@@ -152,3 +159,17 @@ export function validateProspectiveEvent({ store, member, event }) {
|
|
|
152
159
|
}
|
|
153
160
|
return { ok: true };
|
|
154
161
|
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* `todo retire`はlock外で読んだ状態をprior_statusに入れる。append時にStore replayが
|
|
165
|
+
* prior_status不一致や不正遷移で拒否したなら、読込とappendの間に状態が変わった
|
|
166
|
+
* 再試行できる競合であり、破損ではない(u12)。それ以外のerrorはそのまま返す。
|
|
167
|
+
*/
|
|
168
|
+
export function retireStateConflict(error, { planKey, taskId, priorStatus }) {
|
|
169
|
+
if (!(error instanceof TodoStoreError)
|
|
170
|
+
|| !['retire_prior_status_mismatch', 'invalid_retire_transition'].includes(error.detail?.reason)) return error;
|
|
171
|
+
return new TodoStoreError('STORE_WRITE_CONFLICT', 'retire_state_changed', undefined, {
|
|
172
|
+
task_id: taskId, expected: { status: priorStatus },
|
|
173
|
+
next_action: `lattice todo retire --plan ${planKey} --task ${taskId} --reason <text>`,
|
|
174
|
+
});
|
|
175
|
+
}
|
package/src/todo-revision.mjs
CHANGED
|
@@ -69,14 +69,14 @@ export function phaseTodoRevisionPlanVersion({
|
|
|
69
69
|
}) {
|
|
70
70
|
const versionDigest = digestTodoArtifact({
|
|
71
71
|
schema: featureGraphDigest !== null ? 'lattice.phase_todo_revision_version.v3'
|
|
72
|
-
: ['lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(desiredPlan.schema)
|
|
72
|
+
: ['lattice.todo_plan.v5', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(desiredPlan.schema)
|
|
73
73
|
? 'lattice.phase_todo_revision_version.v2' : 'lattice.phase_todo_revision_version.v1', project_id: projectId,
|
|
74
74
|
plan_key: planKey, predecessor, desired_topology: {
|
|
75
75
|
schema: desiredPlan.schema, project_id: desiredPlan.project_id,
|
|
76
76
|
plan_key: desiredPlan.plan_key, predecessor_plan_digest: desiredPlan.predecessor_plan_digest,
|
|
77
77
|
tasks: desiredPlan.tasks, phases: desiredPlan.phases,
|
|
78
78
|
hard_dependencies: desiredPlan.hard_dependencies, joins: desiredPlan.joins,
|
|
79
|
-
...(['lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(desiredPlan.schema)
|
|
79
|
+
...(['lattice.todo_plan.v5', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(desiredPlan.schema)
|
|
80
80
|
? { phase_accept_dependencies: desiredPlan.phase_accept_dependencies } : {}),
|
|
81
81
|
}, task_migration: taskMigration, phase_migration: phaseMigration,
|
|
82
82
|
...(featureGraphDigest === null ? {} : { feature_graph_digest: featureGraphDigest }),
|
|
@@ -303,9 +303,10 @@ export function validatePhaseTodoRevision(value) {
|
|
|
303
303
|
if (!isTodoIdentifier(value.project_id) || !isTodoIdentifier(value.plan_key)) return false;
|
|
304
304
|
if (!validPredecessor(value.predecessor) || !validateTodoPlan(value.desired_plan)
|
|
305
305
|
|| !(revisionV3
|
|
306
|
-
? ['lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(value.desired_plan.schema)
|
|
307
|
-
:
|
|
308
|
-
|
|
306
|
+
? ['lattice.todo_plan.v5', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(value.desired_plan.schema)
|
|
307
|
+
: (revisionV4 || revisionV5)
|
|
308
|
+
? ['lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(value.desired_plan.schema)
|
|
309
|
+
: value.desired_plan.schema === (revisionV2 ? 'lattice.todo_plan.v5' : 'lattice.todo_plan.v4'))
|
|
309
310
|
|| value.desired_plan.project_id !== value.project_id
|
|
310
311
|
|| value.desired_plan.plan_key !== value.plan_key
|
|
311
312
|
|| value.desired_plan.predecessor_plan_digest !== value.predecessor.plan_digest
|
|
@@ -855,9 +856,9 @@ export function explainPhaseTodoRevision(value) {
|
|
|
855
856
|
const predecessorCheck = explainPredecessor(value.predecessor);
|
|
856
857
|
if (!predecessorCheck.valid) return predecessorCheck;
|
|
857
858
|
if (!validateTodoPlan(value.desired_plan)) return reject('desired_plan_invalid', '/desired_plan');
|
|
858
|
-
const expectedPlanSchemas = revisionV3 ? ['lattice.todo_plan.v5', 'lattice.todo_plan.v7']
|
|
859
|
-
:
|
|
860
|
-
:
|
|
859
|
+
const expectedPlanSchemas = revisionV3 ? ['lattice.todo_plan.v5', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8']
|
|
860
|
+
: (revisionV4 || revisionV5) ? ['lattice.todo_plan.v7', 'lattice.todo_plan.v8']
|
|
861
|
+
: [revisionV2 ? 'lattice.todo_plan.v5' : 'lattice.todo_plan.v4'];
|
|
861
862
|
if (!expectedPlanSchemas.includes(value.desired_plan.schema)) {
|
|
862
863
|
return reject('desired_plan_schema_mismatch', '/desired_plan/schema');
|
|
863
864
|
}
|