@quolu/lattice 0.93.0 → 0.95.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 +3 -1
- package/src/todo-cli.mjs +65 -8
- package/src/todo-notices.mjs +10 -3
- package/src/todo-nudges.mjs +37 -0
- package/src/todo-store.mjs +39 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.95.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,7 @@ 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)を促す(読むだけ)
|
|
91
92
|
bindings [--plan <key>] [--json] # compile_binding付きTaskをTODO identityつきで投影する
|
|
92
93
|
display read [--json] # host表示用の工程表読取(lattice.todo_display_read_result.v1)。不整合でも断らずstateで返す
|
|
93
94
|
display source [--json] # 安い変更検知(lattice.todo_store_display_source.v1)。変わった時だけreadする
|
|
@@ -306,6 +307,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
306
307
|
'todo notice': 'todo notice list [--lane <lane>] [--include-acked] [--json] | ack --lane <lane> --notice <id>[,<id>...] [--json]',
|
|
307
308
|
'todo notice list': 'todo notice list [--lane <lane>] [--include-acked] [--json] # lattice.todo_notice_list_result.v1',
|
|
308
309
|
'todo notice ack': 'todo notice ack --lane <lane> --notice <id>[,<id>...] [--json] # lattice.todo_notice_ack_result.v1 {acked, already, closed}',
|
|
310
|
+
'todo nudge': 'todo nudge [--json] # lattice.todo_nudge_result.v1 {lanes: [{lane, tasks: [{fire_actions, stop_action, prompt}]}]}',
|
|
309
311
|
'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
312
|
'todo bindings': 'todo bindings [--plan <key>] [--json]',
|
|
311
313
|
'todo display': 'todo display read [--json] | source [--json] # host表示用の読取。不整合でも断らずstateで返す',
|
|
@@ -347,7 +349,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
347
349
|
'todo done': 'todo done --plan <key> --task <id> [--evidence <file>] [--message <text>] [--test-result <markdown-file>]',
|
|
348
350
|
'todo reopen': 'todo reopen --plan <key> --task <id> --reason <text> [--override-reason <text>]',
|
|
349
351
|
'todo evidence': 'todo evidence promote --plan <key> --task <id> --evidence <file> | anchor [--json]',
|
|
350
|
-
'todo evidence anchor': 'todo evidence anchor [--json] # lattice.todo_evidence_anchor_result.v1 {anchored, already, missing}',
|
|
352
|
+
'todo evidence anchor': 'todo evidence anchor [--json] # lattice.todo_evidence_anchor_result.v1 {anchored, already, missing}; no Store yet: lattice.todo_evidence_anchor_uninitialized.v1',
|
|
351
353
|
'todo evidence promote': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
|
352
354
|
'todo dependency': [
|
|
353
355
|
'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
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,7 @@ 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 { projectTodoNudges } from './todo-nudges.mjs';
|
|
173
174
|
import {
|
|
174
175
|
ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
|
|
175
176
|
} from './todo-notice-store.mjs';
|
|
@@ -307,7 +308,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
307
308
|
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
308
309
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
309
310
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
310
|
-
'retract', 'dependency', 'add', 'notice', 'wait',
|
|
311
|
+
'retract', 'dependency', 'add', 'notice', 'wait', 'nudge',
|
|
311
312
|
]);
|
|
312
313
|
|
|
313
314
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -369,6 +370,7 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
369
370
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
370
371
|
'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
|
|
371
372
|
'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
|
|
373
|
+
nudge: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
372
374
|
wait: Object.freeze({ known: ['plan', 'task', 'reason', 'cancel', 'json'], required: ['plan', 'task'], booleans: ['cancel', 'json'] }),
|
|
373
375
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
374
376
|
'phase status': Object.freeze({ known: ['plan', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
@@ -3863,6 +3865,27 @@ async function scaffoldWitnessDraft({ repoRoot, planKey, draft }) {
|
|
|
3863
3865
|
};
|
|
3864
3866
|
}
|
|
3865
3867
|
|
|
3868
|
+
/**
|
|
3869
|
+
* declare-hint-knows-order: offer `todo start` only for a task the start path accepts now; otherwise name what it
|
|
3870
|
+
* waits on (the blocking set a start refusal computes), so the hint never leads into predecessor_unfinished.
|
|
3871
|
+
*/
|
|
3872
|
+
function declaredStartHint(store, member, state) {
|
|
3873
|
+
const { plan_key: planKey } = member.plan;
|
|
3874
|
+
const taskId = state.task_id;
|
|
3875
|
+
if (state.status !== 'pending') return `${taskId} is already ${state.status}; no start is needed.`;
|
|
3876
|
+
const readiness = createTodoReadiness(store);
|
|
3877
|
+
const key = readiness.key({ ...member.plan, task_id: taskId });
|
|
3878
|
+
if (readiness.isReady(key)) return `The declared task can start: \`lattice todo start --plan ${planKey} --task ${taskId}\`.`;
|
|
3879
|
+
const { blocking } = readiness.prerequisites(key);
|
|
3880
|
+
const waits = [
|
|
3881
|
+
...(blocking.blocking_tasks ?? []).map((ref) => `${ref.plan_key}/${ref.task_id} (${ref.status})`),
|
|
3882
|
+
...(blocking.blocking_phases ?? []).map((ref) => `phase ${ref.plan_key}/${ref.phase_id} (${ref.status})`),
|
|
3883
|
+
];
|
|
3884
|
+
const on = waits.length > 0 ? `it waits on ${waits.join(', ')}`
|
|
3885
|
+
: `its phase is ${readiness.ownPhaseStatus(key) ?? 'not active'}`;
|
|
3886
|
+
return `${taskId} cannot start yet: ${on}. Start it once \`lattice todo status --json\` lists it in next_ready.`;
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3866
3889
|
/**
|
|
3867
3890
|
* a40: one task's witness row, declared by its member. Rows nobody declared stay out (an empty row
|
|
3868
3891
|
* would claim "touches nothing"); compile runs once every ready task is declared.
|
|
@@ -3910,8 +3933,7 @@ async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
|
3910
3933
|
...(observable ? {} : {
|
|
3911
3934
|
observation: 'unavailable',
|
|
3912
3935
|
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}\`.`,
|
|
3936
|
+
+ ` coverage reads declared_unobserved (not judged safe). ${declaredStartHint(store, member, state)}`,
|
|
3915
3937
|
}),
|
|
3916
3938
|
result_digest: '',
|
|
3917
3939
|
};
|
|
@@ -4639,21 +4661,47 @@ function releasesTasks(argv) {
|
|
|
4639
4661
|
|| (command === 'dependency' && second === 'disconnect');
|
|
4640
4662
|
}
|
|
4641
4663
|
|
|
4642
|
-
/**
|
|
4643
|
-
async function
|
|
4644
|
-
const store = await readTodoStore({ repoRoot });
|
|
4664
|
+
/** `declared(planKey, taskId)`: whether an enforced plan's witness set records the task's row (unreadable = none). */
|
|
4665
|
+
async function declaredWitnessRows(repoRoot, store) {
|
|
4645
4666
|
const rows = new Map();
|
|
4646
4667
|
for (const member of store.members) {
|
|
4647
4668
|
if (member.coordination?.mode !== 'enforced') continue;
|
|
4648
4669
|
const recorded = await readTodoWitnessSet({ repoRoot, planKey: member.plan.plan_key }).catch(() => null);
|
|
4649
4670
|
rows.set(member.plan.plan_key, new Set(Object.keys(recorded?.manual_witness ?? {})));
|
|
4650
4671
|
}
|
|
4672
|
+
return (planKey, taskId) => rows.get(planKey)?.has(taskId) === true;
|
|
4673
|
+
}
|
|
4674
|
+
|
|
4675
|
+
/**
|
|
4676
|
+
* `todo nudge` (sweep-list, dfd-nudge.md): the ready set by lane with fire/stop prompts. Read-only. A directory with
|
|
4677
|
+
* no Store yet answers an empty list, since the BellTeam run walks every chart directory.
|
|
4678
|
+
*/
|
|
4679
|
+
async function nudgeList({ repoRoot }) {
|
|
4680
|
+
let store;
|
|
4681
|
+
try { store = await readTodoStore({ repoRoot }); }
|
|
4682
|
+
catch (error) {
|
|
4683
|
+
if (error?.code !== 'STORE_UNINITIALIZED') throw error;
|
|
4684
|
+
store = null;
|
|
4685
|
+
}
|
|
4686
|
+
const result = {
|
|
4687
|
+
schema: 'lattice.todo_nudge_result.v1', project_id: store?.project_id ?? null,
|
|
4688
|
+
lanes: store === null ? [] : projectTodoNudges(store, { declared: await declaredWitnessRows(repoRoot, store) }),
|
|
4689
|
+
result_digest: '',
|
|
4690
|
+
};
|
|
4691
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4692
|
+
return result;
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4695
|
+
/** Open notices with their waiters (wait-design); an unreadable wait file is named, its waits read as none. */
|
|
4696
|
+
async function openNoticeView(repoRoot) {
|
|
4697
|
+
const store = await readTodoStore({ repoRoot });
|
|
4698
|
+
const declared = await declaredWitnessRows(repoRoot, store);
|
|
4651
4699
|
const stored = await readAllTodoNoticeWaits({ repoRoot });
|
|
4652
4700
|
// Readers return raw records: waits that ended since the file's last write are dropped here.
|
|
4653
4701
|
const waits = stored.waits.flatMap((record) => record.waits.map((wait) => ({ plan_key: record.plan_key, ...wait })))
|
|
4654
4702
|
.filter((wait) => waitInEffect(store, wait));
|
|
4655
4703
|
const notices = projectTodoNotices(store, {
|
|
4656
|
-
declared
|
|
4704
|
+
declared, waits,
|
|
4657
4705
|
});
|
|
4658
4706
|
return { store, notices, waitUnreadable: stored.unreadable };
|
|
4659
4707
|
}
|
|
@@ -4879,6 +4927,13 @@ function recordedEvidence(store) {
|
|
|
4879
4927
|
* existing chart. Evidence gc already pruned cannot come back and is listed as `missing`.
|
|
4880
4928
|
*/
|
|
4881
4929
|
async function evidenceAnchor({ repoRoot }) {
|
|
4930
|
+
// No Store yet: nothing recorded, so nothing to anchor. Answer like `todo status` does, not as a broken store.
|
|
4931
|
+
if (await isUninitializedTodoStore({ repoRoot })) {
|
|
4932
|
+
const result = { schema: 'lattice.todo_evidence_anchor_uninitialized.v1', anchored: [], already: 0, missing: [],
|
|
4933
|
+
next_actions: ['lattice plan create --template --json', 'lattice plan create --input <file>'], result_digest: '' };
|
|
4934
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4935
|
+
return result;
|
|
4936
|
+
}
|
|
4882
4937
|
const store = await readTodoStore({ repoRoot });
|
|
4883
4938
|
const anchored = [];
|
|
4884
4939
|
const missing = [];
|
|
@@ -5198,6 +5253,8 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5198
5253
|
if (isNoticeLane(flags.lane) && ids.length > 0 && ids.every((id) => /^[0-9a-f]{64}$/u.test(id))) {
|
|
5199
5254
|
action = (repoRoot) => noticeAck({ repoRoot, env, lane: flags.lane, ids });
|
|
5200
5255
|
}
|
|
5256
|
+
} else if (argv[0] === 'nudge' && matchFlagCommand(argv, ['nudge'], TODO_FLAG_SPECS.nudge) !== null) {
|
|
5257
|
+
action = (repoRoot) => nudgeList({ repoRoot });
|
|
5201
5258
|
} else if (argv[0] === 'wait' && matchFlagCommand(argv, ['wait'], TODO_FLAG_SPECS.wait) !== null) {
|
|
5202
5259
|
const flags = matchFlagCommand(argv, ['wait'], TODO_FLAG_SPECS.wait);
|
|
5203
5260
|
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
|
@@ -113,6 +113,26 @@ function fail(code, reason, detail) {
|
|
|
113
113
|
throw new TodoStoreError(code, reason, reason, detail);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// No Store yet is an empty project, not a broken one (same classification as `status`): never invite repair or deletion.
|
|
117
|
+
function failUninitialized() {
|
|
118
|
+
fail('STORE_UNINITIALIZED', 'store_uninitialized', {
|
|
119
|
+
ref: STORE_ROOT_REF, next_action: 'lattice plan create --template --json',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
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
|
+
|
|
116
136
|
const upgradeAction = (what) => `${what} was written by a newer Lattice than ${packageJson.version}. The record is`
|
|
117
137
|
+ ` not corrupt: do not repair or delete it. Upgrade Lattice on this host to a version newer than`
|
|
118
138
|
+ ` ${packageJson.version}, then run the command again.`;
|
|
@@ -1533,9 +1553,7 @@ async function readTodoStoreView(options = {}) {
|
|
|
1533
1553
|
}
|
|
1534
1554
|
await assertNoCrossPlanImportRecoveryNeeded(repoRoot);
|
|
1535
1555
|
const pinnedSourceCache = { commits: new Set(), blobs: new Map() };
|
|
1536
|
-
const manifest = await
|
|
1537
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1538
|
-
});
|
|
1556
|
+
const manifest = await readManifest(repoRoot);
|
|
1539
1557
|
const loaded = [];
|
|
1540
1558
|
for (const descriptor of manifest.members) {
|
|
1541
1559
|
const plan = await readArtifact(repoRoot, descriptor.plan_ref, {
|
|
@@ -1817,21 +1835,15 @@ async function readStoreStableWith(options, readStore) {
|
|
|
1817
1835
|
// これにより一時窓を早計に破損扱いせず、恒久破損もSTORE_BUSYへ丸めない。
|
|
1818
1836
|
let lastError = null;
|
|
1819
1837
|
for (let attempt = 1; attempt <= maximumAttempts; attempt += 1) {
|
|
1820
|
-
const before = await
|
|
1821
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1822
|
-
});
|
|
1838
|
+
const before = await readManifest(repoRoot);
|
|
1823
1839
|
try {
|
|
1824
1840
|
const store = await readStore(options);
|
|
1825
|
-
const after = await
|
|
1826
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1827
|
-
});
|
|
1841
|
+
const after = await readManifest(repoRoot);
|
|
1828
1842
|
if (before.manifest_digest === after.manifest_digest
|
|
1829
1843
|
&& store.manifest.manifest_digest === after.manifest_digest) return store;
|
|
1830
1844
|
} catch (error) {
|
|
1831
1845
|
if (!(error instanceof TodoStoreError)) throw error;
|
|
1832
|
-
const after = await
|
|
1833
|
-
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoManifest,
|
|
1834
|
-
});
|
|
1846
|
+
const after = await readManifest(repoRoot);
|
|
1835
1847
|
const transientWriteWindow = error.code === 'STORE_INCONSISTENT'
|
|
1836
1848
|
&& ['manifest_journal_head_mismatch', 'manifest_plan_binding_mismatch']
|
|
1837
1849
|
.includes(error.detail.reason);
|
|
@@ -1902,6 +1914,9 @@ async function rawLastEventDigest(repoRoot, ref, { missing = false } = {}) {
|
|
|
1902
1914
|
}
|
|
1903
1915
|
|
|
1904
1916
|
async function readRawManifest(repoRoot) {
|
|
1917
|
+
if (await readRawStoreFile(repoRoot, MANIFEST_REF, TODO_LIMITS.snapshotBytes, { missing: true }) === null) {
|
|
1918
|
+
await failManifestMissing(repoRoot);
|
|
1919
|
+
}
|
|
1905
1920
|
const manifest = await readRawStoreJson(repoRoot, MANIFEST_REF, TODO_LIMITS.snapshotBytes);
|
|
1906
1921
|
if (manifest === null || typeof manifest !== 'object' || !Array.isArray(manifest.members)) {
|
|
1907
1922
|
fail('STORE_INCONSISTENT', 'manifest_members_unenumerable', { ref: MANIFEST_REF });
|
|
@@ -2052,7 +2067,15 @@ async function readRawDisplayMembers(repoRoot, manifest) {
|
|
|
2052
2067
|
/** Cheap unverified change hint for display polling; never validation or recovery. */
|
|
2053
2068
|
export async function readTodoStoreDisplaySource({ repoRoot = process.cwd() } = {}) {
|
|
2054
2069
|
const root = path.resolve(repoRoot);
|
|
2055
|
-
|
|
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);
|
|
2056
2079
|
}
|
|
2057
2080
|
|
|
2058
2081
|
/** Display-only envelope: verified > unverified current raw > last_verified > unavailable. */
|
|
@@ -2162,11 +2185,11 @@ async function withLock(repoRoot, callback, {
|
|
|
2162
2185
|
try {
|
|
2163
2186
|
if (!initialize) {
|
|
2164
2187
|
const root = await lstat(path.join(repoRoot, STORE_ROOT_REF)).catch((error) => {
|
|
2165
|
-
if (error?.code === 'ENOENT')
|
|
2188
|
+
if (error?.code === 'ENOENT') failUninitialized();
|
|
2166
2189
|
throw error;
|
|
2167
2190
|
});
|
|
2168
2191
|
const parent = await lstat(path.join(repoRoot, '.lattice')).catch((error) => {
|
|
2169
|
-
if (error?.code === 'ENOENT')
|
|
2192
|
+
if (error?.code === 'ENOENT') failUninitialized();
|
|
2170
2193
|
throw error;
|
|
2171
2194
|
});
|
|
2172
2195
|
if (!root.isDirectory() || root.isSymbolicLink()
|
|
@@ -3546,7 +3569,7 @@ async function prepareAuthoredStoreRoot(repoRoot, options) {
|
|
|
3546
3569
|
}); } catch (error) {
|
|
3547
3570
|
const gone = (await uninitializedStoreLayout(repoRoot)).identity === null;
|
|
3548
3571
|
if (gone && error instanceof TodoStoreError
|
|
3549
|
-
&& ['store_locked', 'artifact_missing'].includes(error.detail.reason)) return;
|
|
3572
|
+
&& ['store_locked', 'artifact_missing', 'store_uninitialized'].includes(error.detail.reason)) return;
|
|
3550
3573
|
throw error;
|
|
3551
3574
|
}
|
|
3552
3575
|
await protocolStage(options, 'authoring_residue_released');
|