@quolu/lattice 0.94.0 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli-help.mjs +4 -0
- package/src/todo-blockers.mjs +29 -0
- package/src/todo-cli.mjs +78 -8
- package/src/todo-notices.mjs +10 -3
- package/src/todo-nudges.mjs +37 -0
- package/src/todo-store.mjs +29 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
package/src/cli-help.mjs
CHANGED
|
@@ -88,6 +88,8 @@ Read commands:
|
|
|
88
88
|
show --plan <key> --task <id> --json # 個別ToDoと最新bounded note contextを追加操作なしで返す
|
|
89
89
|
note list --plan <key> [--task <id>] --json # note全履歴の診断面(通常read/startでは不要)
|
|
90
90
|
notice list [--lane <lane>] [--include-acked] [--json] # 着手できるようになった工程の知らせ(既定は未ackだけ。lane省略で全lane)
|
|
91
|
+
nudge [--json] # 前の工程が終わっているのに未着手の工程を担当ごとに返し、発火(着手)と、動けない時の止め(todo block)を促す(読むだけ)
|
|
92
|
+
blockers [--json] # 止めのある工程を全部返す(題・担当・理由の全文・止めた時刻と者・外すコマンド。読むだけ。外すのは誰でも todo unblock)
|
|
91
93
|
bindings [--plan <key>] [--json] # compile_binding付きTaskをTODO identityつきで投影する
|
|
92
94
|
display read [--json] # host表示用の工程表読取(lattice.todo_display_read_result.v1)。不整合でも断らずstateで返す
|
|
93
95
|
display source [--json] # 安い変更検知(lattice.todo_store_display_source.v1)。変わった時だけreadする
|
|
@@ -306,6 +308,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
306
308
|
'todo notice': 'todo notice list [--lane <lane>] [--include-acked] [--json] | ack --lane <lane> --notice <id>[,<id>...] [--json]',
|
|
307
309
|
'todo notice list': 'todo notice list [--lane <lane>] [--include-acked] [--json] # lattice.todo_notice_list_result.v1',
|
|
308
310
|
'todo notice ack': 'todo notice ack --lane <lane> --notice <id>[,<id>...] [--json] # lattice.todo_notice_ack_result.v1 {acked, already, closed}',
|
|
311
|
+
'todo nudge': 'todo nudge [--json] # lattice.todo_nudge_result.v1 {lanes: [{lane, tasks: [{fire_actions, stop_action, prompt}]}]}',
|
|
312
|
+
'todo blockers': 'todo blockers [--json] # lattice.todo_blockers_result.v1 {blockers: [{plan_key, task_id, title, lane, reason, blocked_at, blocked_by, unblock_action}]}',
|
|
309
313
|
'todo wait': 'todo wait --plan <key> --task <id> [--reason <text>] | --cancel [--json] # lattice.todo_wait_result.v1 {state: waiting|startable_now|not_pending|cancelled}',
|
|
310
314
|
'todo bindings': 'todo bindings [--plan <key>] [--json]',
|
|
311
315
|
'todo display': 'todo display read [--json] | source [--json] # host表示用の読取。不整合でも断らずstateで返す',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Blockers (blockers-list, docs/architecture/dfd-blockers.md): every blocked task in the chart with its full reason,
|
|
2
|
+
// who stopped it and when, and the command to lift it. Read-only; `todo unblock` stays open to any seat.
|
|
3
|
+
|
|
4
|
+
/** Blocked tasks of every member, sorted by plan_key then task_id. */
|
|
5
|
+
export function projectTodoBlockers(store) {
|
|
6
|
+
const blockers = [];
|
|
7
|
+
for (const member of store.members) {
|
|
8
|
+
const planKey = member.plan.plan_key;
|
|
9
|
+
const lastBlock = new Map();
|
|
10
|
+
for (const event of member.journal.events) if (event.kind === 'block') lastBlock.set(event.task_id, event);
|
|
11
|
+
for (const state of member.tasks) {
|
|
12
|
+
if (state.status !== 'blocked') continue;
|
|
13
|
+
const task = member.plan.tasks.find(({ task_id: id }) => id === state.task_id);
|
|
14
|
+
const event = lastBlock.get(state.task_id);
|
|
15
|
+
blockers.push({
|
|
16
|
+
plan_key: planKey,
|
|
17
|
+
task_id: state.task_id,
|
|
18
|
+
title: task?.title ?? null,
|
|
19
|
+
lane: task?.lane ?? null,
|
|
20
|
+
reason: state.blocked_reason,
|
|
21
|
+
blocked_at: event?.recorded_at ?? null,
|
|
22
|
+
blocked_by: event?.actor ?? null,
|
|
23
|
+
unblock_action: `lattice todo unblock --plan ${planKey} --task ${state.task_id}`,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const key = ({ plan_key: plan, task_id: task }) => `${plan}\u0000${task}`;
|
|
28
|
+
return blockers.sort((left, right) => (key(left) < key(right) ? -1 : 1));
|
|
29
|
+
}
|
package/src/todo-cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { retireStateConflict, validateProspectiveEvent } from './todo-readiness.mjs';
|
|
1
|
+
import { createTodoReadiness, retireStateConflict, validateProspectiveEvent } from './todo-readiness.mjs';
|
|
2
2
|
import { cliCommandKind } from './cli-command-kind.mjs';
|
|
3
3
|
import { cliFailureClass } from './cli-failure-class.mjs';
|
|
4
4
|
import { ENFORCED_DONE_MESSAGE, FLAG_PLACEHOLDER, publicRefusalCode, withRefusalGuidance } from './cli-refusal-guidance.mjs';
|
|
@@ -170,6 +170,8 @@ import {
|
|
|
170
170
|
import { compileSeamProposalArtifact, declaredConcernSymbols } from './seam-proposal.mjs';
|
|
171
171
|
import { collectSensorEvidence } from './sensor-adapter.mjs';
|
|
172
172
|
import { newTodoNotices, projectTodoNotices, waitInEffect } from './todo-notices.mjs';
|
|
173
|
+
import { projectTodoBlockers } from './todo-blockers.mjs';
|
|
174
|
+
import { projectTodoNudges } from './todo-nudges.mjs';
|
|
173
175
|
import {
|
|
174
176
|
ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
|
|
175
177
|
} from './todo-notice-store.mjs';
|
|
@@ -307,7 +309,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
307
309
|
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
308
310
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
309
311
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
310
|
-
'retract', 'dependency', 'add', 'notice', 'wait',
|
|
312
|
+
'retract', 'dependency', 'add', 'notice', 'wait', 'nudge', 'blockers',
|
|
311
313
|
]);
|
|
312
314
|
|
|
313
315
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -369,6 +371,8 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
369
371
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
370
372
|
'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
|
|
371
373
|
'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
|
|
374
|
+
nudge: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
375
|
+
blockers: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
372
376
|
wait: Object.freeze({ known: ['plan', 'task', 'reason', 'cancel', 'json'], required: ['plan', 'task'], booleans: ['cancel', 'json'] }),
|
|
373
377
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
374
378
|
'phase status': Object.freeze({ known: ['plan', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
@@ -3863,6 +3867,27 @@ async function scaffoldWitnessDraft({ repoRoot, planKey, draft }) {
|
|
|
3863
3867
|
};
|
|
3864
3868
|
}
|
|
3865
3869
|
|
|
3870
|
+
/**
|
|
3871
|
+
* declare-hint-knows-order: offer `todo start` only for a task the start path accepts now; otherwise name what it
|
|
3872
|
+
* waits on (the blocking set a start refusal computes), so the hint never leads into predecessor_unfinished.
|
|
3873
|
+
*/
|
|
3874
|
+
function declaredStartHint(store, member, state) {
|
|
3875
|
+
const { plan_key: planKey } = member.plan;
|
|
3876
|
+
const taskId = state.task_id;
|
|
3877
|
+
if (state.status !== 'pending') return `${taskId} is already ${state.status}; no start is needed.`;
|
|
3878
|
+
const readiness = createTodoReadiness(store);
|
|
3879
|
+
const key = readiness.key({ ...member.plan, task_id: taskId });
|
|
3880
|
+
if (readiness.isReady(key)) return `The declared task can start: \`lattice todo start --plan ${planKey} --task ${taskId}\`.`;
|
|
3881
|
+
const { blocking } = readiness.prerequisites(key);
|
|
3882
|
+
const waits = [
|
|
3883
|
+
...(blocking.blocking_tasks ?? []).map((ref) => `${ref.plan_key}/${ref.task_id} (${ref.status})`),
|
|
3884
|
+
...(blocking.blocking_phases ?? []).map((ref) => `phase ${ref.plan_key}/${ref.phase_id} (${ref.status})`),
|
|
3885
|
+
];
|
|
3886
|
+
const on = waits.length > 0 ? `it waits on ${waits.join(', ')}`
|
|
3887
|
+
: `its phase is ${readiness.ownPhaseStatus(key) ?? 'not active'}`;
|
|
3888
|
+
return `${taskId} cannot start yet: ${on}. Start it once \`lattice todo status --json\` lists it in next_ready.`;
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3866
3891
|
/**
|
|
3867
3892
|
* a40: one task's witness row, declared by its member. Rows nobody declared stay out (an empty row
|
|
3868
3893
|
* would claim "touches nothing"); compile runs once every ready task is declared.
|
|
@@ -3910,8 +3935,7 @@ async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
|
3910
3935
|
...(observable ? {} : {
|
|
3911
3936
|
observation: 'unavailable',
|
|
3912
3937
|
next_action: `The Store root has no commit (git HEAD unresolved), so ${taskId}'s row is recorded but not observed or compiled:`
|
|
3913
|
-
+
|
|
3914
|
-
+ ` \`lattice todo start --plan ${planKey} --task ${taskId}\`.`,
|
|
3938
|
+
+ ` coverage reads declared_unobserved (not judged safe). ${declaredStartHint(store, member, state)}`,
|
|
3915
3939
|
}),
|
|
3916
3940
|
result_digest: '',
|
|
3917
3941
|
};
|
|
@@ -4639,21 +4663,63 @@ function releasesTasks(argv) {
|
|
|
4639
4663
|
|| (command === 'dependency' && second === 'disconnect');
|
|
4640
4664
|
}
|
|
4641
4665
|
|
|
4642
|
-
/**
|
|
4643
|
-
async function
|
|
4644
|
-
const store = await readTodoStore({ repoRoot });
|
|
4666
|
+
/** `declared(planKey, taskId)`: whether an enforced plan's witness set records the task's row (unreadable = none). */
|
|
4667
|
+
async function declaredWitnessRows(repoRoot, store) {
|
|
4645
4668
|
const rows = new Map();
|
|
4646
4669
|
for (const member of store.members) {
|
|
4647
4670
|
if (member.coordination?.mode !== 'enforced') continue;
|
|
4648
4671
|
const recorded = await readTodoWitnessSet({ repoRoot, planKey: member.plan.plan_key }).catch(() => null);
|
|
4649
4672
|
rows.set(member.plan.plan_key, new Set(Object.keys(recorded?.manual_witness ?? {})));
|
|
4650
4673
|
}
|
|
4674
|
+
return (planKey, taskId) => rows.get(planKey)?.has(taskId) === true;
|
|
4675
|
+
}
|
|
4676
|
+
|
|
4677
|
+
/**
|
|
4678
|
+
* `todo nudge` (sweep-list, dfd-nudge.md): the ready set by lane with fire/stop prompts. Read-only. A directory with
|
|
4679
|
+
* no Store yet answers an empty list, since the BellTeam run walks every chart directory.
|
|
4680
|
+
*/
|
|
4681
|
+
async function nudgeList({ repoRoot }) {
|
|
4682
|
+
const store = await readTodoStoreOrNull(repoRoot);
|
|
4683
|
+
const result = {
|
|
4684
|
+
schema: 'lattice.todo_nudge_result.v1', project_id: store?.project_id ?? null,
|
|
4685
|
+
lanes: store === null ? [] : projectTodoNudges(store, { declared: await declaredWitnessRows(repoRoot, store) }),
|
|
4686
|
+
result_digest: '',
|
|
4687
|
+
};
|
|
4688
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4689
|
+
return result;
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
/** The Store, or null where none exists yet (the BellTeam reads walk every chart directory). */
|
|
4693
|
+
async function readTodoStoreOrNull(repoRoot) {
|
|
4694
|
+
try { return await readTodoStore({ repoRoot }); }
|
|
4695
|
+
catch (error) {
|
|
4696
|
+
if (error?.code !== 'STORE_UNINITIALIZED') throw error;
|
|
4697
|
+
return null;
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
|
|
4701
|
+
/** `todo blockers` (blockers-list, dfd-blockers.md): every blocked task with its full reason and unblock command. */
|
|
4702
|
+
async function blockerList({ repoRoot }) {
|
|
4703
|
+
const store = await readTodoStoreOrNull(repoRoot);
|
|
4704
|
+
const result = {
|
|
4705
|
+
schema: 'lattice.todo_blockers_result.v1', project_id: store?.project_id ?? null,
|
|
4706
|
+
blockers: store === null ? [] : projectTodoBlockers(store),
|
|
4707
|
+
result_digest: '',
|
|
4708
|
+
};
|
|
4709
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4710
|
+
return result;
|
|
4711
|
+
}
|
|
4712
|
+
|
|
4713
|
+
/** Open notices with their waiters (wait-design); an unreadable wait file is named, its waits read as none. */
|
|
4714
|
+
async function openNoticeView(repoRoot) {
|
|
4715
|
+
const store = await readTodoStore({ repoRoot });
|
|
4716
|
+
const declared = await declaredWitnessRows(repoRoot, store);
|
|
4651
4717
|
const stored = await readAllTodoNoticeWaits({ repoRoot });
|
|
4652
4718
|
// Readers return raw records: waits that ended since the file's last write are dropped here.
|
|
4653
4719
|
const waits = stored.waits.flatMap((record) => record.waits.map((wait) => ({ plan_key: record.plan_key, ...wait })))
|
|
4654
4720
|
.filter((wait) => waitInEffect(store, wait));
|
|
4655
4721
|
const notices = projectTodoNotices(store, {
|
|
4656
|
-
declared
|
|
4722
|
+
declared, waits,
|
|
4657
4723
|
});
|
|
4658
4724
|
return { store, notices, waitUnreadable: stored.unreadable };
|
|
4659
4725
|
}
|
|
@@ -5205,6 +5271,10 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5205
5271
|
if (isNoticeLane(flags.lane) && ids.length > 0 && ids.every((id) => /^[0-9a-f]{64}$/u.test(id))) {
|
|
5206
5272
|
action = (repoRoot) => noticeAck({ repoRoot, env, lane: flags.lane, ids });
|
|
5207
5273
|
}
|
|
5274
|
+
} else if (argv[0] === 'nudge' && matchFlagCommand(argv, ['nudge'], TODO_FLAG_SPECS.nudge) !== null) {
|
|
5275
|
+
action = (repoRoot) => nudgeList({ repoRoot });
|
|
5276
|
+
} else if (argv[0] === 'blockers' && matchFlagCommand(argv, ['blockers'], TODO_FLAG_SPECS.blockers) !== null) {
|
|
5277
|
+
action = (repoRoot) => blockerList({ repoRoot });
|
|
5208
5278
|
} else if (argv[0] === 'wait' && matchFlagCommand(argv, ['wait'], TODO_FLAG_SPECS.wait) !== null) {
|
|
5209
5279
|
const flags = matchFlagCommand(argv, ['wait'], TODO_FLAG_SPECS.wait);
|
|
5210
5280
|
const reasonOk = flags.reason === undefined
|
package/src/todo-notices.mjs
CHANGED
|
@@ -21,6 +21,15 @@ function triggerOf(member, event, ref) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** The start path a lane can run for a ready task, in order: witness declare first on an enforced plan without its row. */
|
|
25
|
+
export function startPath(planKey, taskId, mode, declared) {
|
|
26
|
+
return [
|
|
27
|
+
...(mode === 'enforced' && !declared
|
|
28
|
+
? [`lattice todo independence witness declare --plan ${planKey} --task ${taskId} --owns <path>[,<path>...]`] : []),
|
|
29
|
+
`lattice todo start --plan ${planKey} --task ${taskId}`,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* wait-design: a wait is in effect while its task is pending or blocked and has no own start or retire after `since`.
|
|
26
35
|
* shortcut: a start-then-retract in an earlier plan version followed by a revise can bring a wait back (that version's
|
|
@@ -95,9 +104,7 @@ export function projectTodoNotices(store, { lane = null, declared = () => true,
|
|
|
95
104
|
waiting_digest: todoNoticeWaitingDigest(waiting.map(({ agent, since }) => ({ agent, since }))),
|
|
96
105
|
summary: noticeSummary(planKey, task, waiting),
|
|
97
106
|
// The command if the lane starts; information, never an assignment. Same rule as the enforced done hints (#141): offer what the start path accepts.
|
|
98
|
-
next_action:
|
|
99
|
-
? `lattice todo independence witness declare --plan ${planKey} --task ${task.task_id} --owns <path>[,<path>...]`
|
|
100
|
-
: `lattice todo start --plan ${planKey} --task ${task.task_id}`,
|
|
107
|
+
next_action: startPath(planKey, task.task_id, mode, declared(planKey, task.task_id))[0],
|
|
101
108
|
});
|
|
102
109
|
}
|
|
103
110
|
return notices.sort((left, right) => byText(`${left.plan_key}\0${left.task_id}`, `${right.plan_key}\0${right.task_id}`));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Nudges (sweep-list, docs/architecture/dfd-nudge.md): the ready set grouped by lane, each task with the prompt to
|
|
2
|
+
// fire it and, if it cannot move once fired, to set a stop. Read-only; no other condition (the Owner's spec).
|
|
3
|
+
|
|
4
|
+
import { startPath } from './todo-notices.mjs';
|
|
5
|
+
import { projectTodoStatus, TODO_STATUS_DISPATCH_ONLY } from './todo-status.mjs';
|
|
6
|
+
|
|
7
|
+
const laneOrder = (lane) => (lane === null ? '\u{10FFFF}' : lane);
|
|
8
|
+
|
|
9
|
+
/** `declared(planKey, taskId)` says whether an enforced plan's witness set records the task's row. */
|
|
10
|
+
export function projectTodoNudges(store, { declared = () => true } = {}) {
|
|
11
|
+
const members = new Map(store.members.map((member) => [member.plan.plan_key, member]));
|
|
12
|
+
const lanes = new Map();
|
|
13
|
+
for (const ready of projectTodoStatus(store, TODO_STATUS_DISPATCH_ONLY).next_ready) {
|
|
14
|
+
const member = members.get(ready.plan_key);
|
|
15
|
+
const task = member?.plan.tasks.find(({ task_id: id }) => id === ready.task_id);
|
|
16
|
+
if (task === undefined) continue;
|
|
17
|
+
const planKey = member.plan.plan_key;
|
|
18
|
+
const fire = startPath(planKey, task.task_id, member.coordination?.mode ?? null, declared(planKey, task.task_id));
|
|
19
|
+
const stop = `lattice todo block --plan ${planKey} --task ${task.task_id} --reason <why it cannot move>`;
|
|
20
|
+
const lane = task.lane ?? null;
|
|
21
|
+
if (!lanes.has(lane)) lanes.set(lane, []);
|
|
22
|
+
lanes.get(lane).push({
|
|
23
|
+
plan_key: planKey,
|
|
24
|
+
plan_version: member.plan.plan_version,
|
|
25
|
+
task_id: task.task_id,
|
|
26
|
+
title: task.title,
|
|
27
|
+
done_condition: task.done_condition ?? null,
|
|
28
|
+
fire_actions: fire,
|
|
29
|
+
stop_action: stop,
|
|
30
|
+
prompt: `${planKey}/${task.task_id} 「${task.title}」: its predecessors are finished and it is not started.`
|
|
31
|
+
+ ` Fire it: ${fire.map((command) => `\`${command}\``).join(' then ')}.`
|
|
32
|
+
+ ` If it cannot move once fired, set a stop: \`${stop}\`.`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return [...lanes].sort(([left], [right]) => (laneOrder(left) < laneOrder(right) ? -1 : 1))
|
|
36
|
+
.map(([lane, tasks]) => ({ lane, tasks }));
|
|
37
|
+
}
|
package/src/todo-store.mjs
CHANGED
|
@@ -120,6 +120,19 @@ function failUninitialized() {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** Absent manifest: uninitialized when no Store exists yet; a Store without its manifest stays STORE_INCONSISTENT. */
|
|
124
|
+
async function failManifestMissing(repoRoot) {
|
|
125
|
+
if (await isUninitializedTodoStore({ repoRoot })) failUninitialized();
|
|
126
|
+
fail('STORE_INCONSISTENT', 'artifact_missing', { ref: MANIFEST_REF });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function readManifest(repoRoot) {
|
|
130
|
+
const manifest = await readArtifact(repoRoot, MANIFEST_REF, {
|
|
131
|
+
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest, missing: true,
|
|
132
|
+
});
|
|
133
|
+
return manifest ?? failManifestMissing(repoRoot);
|
|
134
|
+
}
|
|
135
|
+
|
|
123
136
|
const upgradeAction = (what) => `${what} was written by a newer Lattice than ${packageJson.version}. The record is`
|
|
124
137
|
+ ` not corrupt: do not repair or delete it. Upgrade Lattice on this host to a version newer than`
|
|
125
138
|
+ ` ${packageJson.version}, then run the command again.`;
|
|
@@ -1540,13 +1553,7 @@ async function readTodoStoreView(options = {}) {
|
|
|
1540
1553
|
}
|
|
1541
1554
|
await assertNoCrossPlanImportRecoveryNeeded(repoRoot);
|
|
1542
1555
|
const pinnedSourceCache = { commits: new Set(), blobs: new Map() };
|
|
1543
|
-
const manifest = await
|
|
1544
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest, missing: true,
|
|
1545
|
-
});
|
|
1546
|
-
if (manifest === null) {
|
|
1547
|
-
if (await isUninitializedTodoStore({ repoRoot })) failUninitialized();
|
|
1548
|
-
fail('STORE_INCONSISTENT', 'artifact_missing', { ref: MANIFEST_REF });
|
|
1549
|
-
}
|
|
1556
|
+
const manifest = await readManifest(repoRoot);
|
|
1550
1557
|
const loaded = [];
|
|
1551
1558
|
for (const descriptor of manifest.members) {
|
|
1552
1559
|
const plan = await readArtifact(repoRoot, descriptor.plan_ref, {
|
|
@@ -1828,21 +1835,15 @@ async function readStoreStableWith(options, readStore) {
|
|
|
1828
1835
|
// これにより一時窓を早計に破損扱いせず、恒久破損もSTORE_BUSYへ丸めない。
|
|
1829
1836
|
let lastError = null;
|
|
1830
1837
|
for (let attempt = 1; attempt <= maximumAttempts; attempt += 1) {
|
|
1831
|
-
const before = await
|
|
1832
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1833
|
-
});
|
|
1838
|
+
const before = await readManifest(repoRoot);
|
|
1834
1839
|
try {
|
|
1835
1840
|
const store = await readStore(options);
|
|
1836
|
-
const after = await
|
|
1837
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1838
|
-
});
|
|
1841
|
+
const after = await readManifest(repoRoot);
|
|
1839
1842
|
if (before.manifest_digest === after.manifest_digest
|
|
1840
1843
|
&& store.manifest.manifest_digest === after.manifest_digest) return store;
|
|
1841
1844
|
} catch (error) {
|
|
1842
1845
|
if (!(error instanceof TodoStoreError)) throw error;
|
|
1843
|
-
const after = await
|
|
1844
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1845
|
-
});
|
|
1846
|
+
const after = await readManifest(repoRoot);
|
|
1846
1847
|
const transientWriteWindow = error.code === 'STORE_INCONSISTENT'
|
|
1847
1848
|
&& ['manifest_journal_head_mismatch', 'manifest_plan_binding_mismatch']
|
|
1848
1849
|
.includes(error.detail.reason);
|
|
@@ -1913,6 +1914,9 @@ async function rawLastEventDigest(repoRoot, ref, { missing = false } = {}) {
|
|
|
1913
1914
|
}
|
|
1914
1915
|
|
|
1915
1916
|
async function readRawManifest(repoRoot) {
|
|
1917
|
+
if (await readRawStoreFile(repoRoot, MANIFEST_REF, TODO_LIMITS.snapshotBytes, { missing: true }) === null) {
|
|
1918
|
+
await failManifestMissing(repoRoot);
|
|
1919
|
+
}
|
|
1916
1920
|
const manifest = await readRawStoreJson(repoRoot, MANIFEST_REF, TODO_LIMITS.snapshotBytes);
|
|
1917
1921
|
if (manifest === null || typeof manifest !== 'object' || !Array.isArray(manifest.members)) {
|
|
1918
1922
|
fail('STORE_INCONSISTENT', 'manifest_members_unenumerable', { ref: MANIFEST_REF });
|
|
@@ -2063,7 +2067,15 @@ async function readRawDisplayMembers(repoRoot, manifest) {
|
|
|
2063
2067
|
/** Cheap unverified change hint for display polling; never validation or recovery. */
|
|
2064
2068
|
export async function readTodoStoreDisplaySource({ repoRoot = process.cwd() } = {}) {
|
|
2065
2069
|
const root = path.resolve(repoRoot);
|
|
2066
|
-
|
|
2070
|
+
let manifest;
|
|
2071
|
+
try { manifest = await readRawManifest(root); } catch (error) {
|
|
2072
|
+
// No Store yet is an observation like display read's, not a probe failure.
|
|
2073
|
+
if (error?.code !== 'STORE_UNINITIALIZED') throw error;
|
|
2074
|
+
const source = await observeDisplaySource(root, { members: [] });
|
|
2075
|
+
source.diagnostics.push({ plan_key: null, field: 'manifest', code: error.code, reason: error.detail.reason });
|
|
2076
|
+
return source;
|
|
2077
|
+
}
|
|
2078
|
+
return observeDisplaySource(root, manifest);
|
|
2067
2079
|
}
|
|
2068
2080
|
|
|
2069
2081
|
/** Display-only envelope: verified > unverified current raw > last_verified > unavailable. */
|