@quolu/lattice 0.85.4 → 0.86.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.mjs +2 -2
- package/package.json +1 -1
- package/src/cli-help.mjs +14 -2
- package/src/plan-revise.mjs +19 -2
- package/src/project-cli.mjs +2 -0
- package/src/store-lock.mjs +30 -5
- package/src/todo-cli.mjs +74 -2
- package/src/todo-note-store.mjs +2 -2
- package/src/todo-store.mjs +2 -1
package/bin/lattice.mjs
CHANGED
|
@@ -140,7 +140,7 @@ if (help !== null) {
|
|
|
140
140
|
} else if (args[0] === 'plan' && args[1] === 'revise') {
|
|
141
141
|
const { matchFlagCommand } = await import('../src/todo-authoring-input.mjs');
|
|
142
142
|
const spec = {
|
|
143
|
-
known: ['input', 'dry-run', 'json'], required: ['input'], booleans: ['dry-run', 'json'],
|
|
143
|
+
known: ['plan', 'input', 'dry-run', 'json'], required: ['input'], booleans: ['dry-run', 'json'],
|
|
144
144
|
};
|
|
145
145
|
const flags = matchFlagCommand(args, ['plan', 'revise'], spec);
|
|
146
146
|
if (flags === null || flags.json !== true) {
|
|
@@ -150,7 +150,7 @@ if (help !== null) {
|
|
|
150
150
|
const { runPlanRevise } = await import('../src/plan-revise.mjs');
|
|
151
151
|
const { projectCliFailure } = await import('../src/project-cli.mjs');
|
|
152
152
|
try {
|
|
153
|
-
process.exitCode = await runPlanRevise({ cwd: process.cwd(), inputRef: flags.input,
|
|
153
|
+
process.exitCode = await runPlanRevise({ cwd: process.cwd(), inputRef: flags.input, planKey: flags.plan,
|
|
154
154
|
dryRun: flags['dry-run'] === true, stdout: process.stdout, env: process.env });
|
|
155
155
|
} catch (error) {
|
|
156
156
|
process.exitCode = projectCliFailure(process.stderr, error, { command: 'revise', flags });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.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
|
@@ -31,7 +31,8 @@ Commands:
|
|
|
31
31
|
create --schema-version <1|2|3|4|5> --json
|
|
32
32
|
create --template --json # 作者が書くkeyだけの最小のv5入力(そのままplan createが受理する)
|
|
33
33
|
backchain --schema --json # 最終成果から必要な機能を逆算する入力契約
|
|
34
|
-
revise --input <file> [--dry-run] [--json]
|
|
34
|
+
revise [--plan <key>] --input <file> [--dry-run] [--json]
|
|
35
|
+
# --planは任意。入力にplan_keyが無ければ補い、違えばplan_revise_plan_key_mismatchで断る
|
|
35
36
|
# 改訂後の計画の全体を、plan createと同じ形で渡す(plan create --template --jsonから始められる)。
|
|
36
37
|
# 継続方針を自分で書くなら {"schema":"lattice.plan_revise_input.v1","desired":<計画>,"continuity":[...]}
|
|
37
38
|
revise --schema --json
|
|
@@ -87,6 +88,8 @@ Read commands:
|
|
|
87
88
|
show --plan <key> --task <id> --json # 個別ToDoと最新bounded note contextを追加操作なしで返す
|
|
88
89
|
note list --plan <key> [--task <id>] --json # note全履歴の診断面(通常read/startでは不要)
|
|
89
90
|
bindings [--plan <key>] [--json] # compile_binding付きTaskをTODO identityつきで投影する
|
|
91
|
+
display read [--json] # host表示用の工程表読取(lattice.todo_display_read_result.v1)。不整合でも断らずstateで返す
|
|
92
|
+
display source [--json] # 安い変更検知(lattice.todo_store_display_source.v1)。変わった時だけreadする
|
|
90
93
|
independence [--plan <key>] [--json] # readyを検証済み並列・要直列・未検査へ分けて投影する
|
|
91
94
|
structure --schema --json # plan定義後に入力する論理dataflow契約をstore非依存で返す
|
|
92
95
|
structure [--plan <key>] --json # 保存済み構造をsensor再実行なしでfreshness・finding付き投影する
|
|
@@ -119,6 +122,10 @@ Write commands:
|
|
|
119
122
|
block --plan <key> --task <id> --reason <text>
|
|
120
123
|
unblock --plan <key> --task <id>
|
|
121
124
|
retire --plan <key> --task <id> --reason <text>
|
|
125
|
+
# 1件を閉じる。planは書き直さず、他のtaskの状態とjournalはそのまま
|
|
126
|
+
add --plan <key> --task <id> --title <text> [--phase <id>] [--lane <lane>] [--done-condition <text>]
|
|
127
|
+
[--design-memo <text>] [--after <id>[,<id>...]] [--before <id>[,<id>...]] [--reason <text>]
|
|
128
|
+
# 1件を足す(a39)。planの全体を書かずに軽量改訂で新plan_versionを作り、他のtaskはcarry
|
|
122
129
|
done --plan <key> --task <id> [--evidence <file>] [--message <text>]
|
|
123
130
|
# taskを閉じる。どちらも省略でき、両方なら本文がfileを名指す(A58)。--evidenceはdescriptor JSONでも証拠本文でもよい。repo内なら絶対path可。
|
|
124
131
|
# 既にdoneなら何も足さずunchanged:trueで成功する(a12)
|
|
@@ -251,7 +258,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
251
258
|
'plan show': 'plan show <plan_key> --json',
|
|
252
259
|
'plan scope-review': 'plan scope-review --plan-input <plan-create-or-extraction.json> --review <scope-review.json> --json | --schema --json',
|
|
253
260
|
'plan backchain': 'plan backchain --input <file> [--dry-run] [--json] | --schema --json',
|
|
254
|
-
'plan revise': 'plan revise --input <file> [--dry-run] [--json] | --schema --json\n\n'
|
|
261
|
+
'plan revise': 'plan revise [--plan <key>] --input <file> [--dry-run] [--json] | --schema --json\n\n'
|
|
255
262
|
+ '--input: the whole desired plan in the same shape as `plan create` (start from `plan create --template --json`),\n'
|
|
256
263
|
+ 'or {"schema":"lattice.plan_revise_input.v1","desired":<that plan>,"continuity":[{task_id, policy: carry|reset|retire, reason}]}.\n'
|
|
257
264
|
+ 'Without continuity the machine computes carry/reset/retire. A plan_key with no active plan is made with `plan create`.',
|
|
@@ -290,6 +297,9 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
290
297
|
'todo note': 'todo note --plan <key> [--task <id>] (--message <text>|--input <file>) | list --plan <key> [--task <id>] --json',
|
|
291
298
|
'todo note list': 'todo note list --plan <key> [--task <id>] [--json]',
|
|
292
299
|
'todo bindings': 'todo bindings [--plan <key>] [--json]',
|
|
300
|
+
'todo display': 'todo display read [--json] | source [--json] # host表示用の読取。不整合でも断らずstateで返す',
|
|
301
|
+
'todo display read': 'todo display read [--json] # lattice.todo_display_read_result.v1(state: verified|unverified|last_verified|unavailable)',
|
|
302
|
+
'todo display source': 'todo display source [--json] # lattice.todo_store_display_source.v1(安い変更検知。変わった時だけreadする)',
|
|
293
303
|
'todo independence': 'todo independence [--plan <key>] [--json] | mode --plan <key> --set <witness|conversation> --reason <text>'
|
|
294
304
|
+ ' | compile --plan <key> --input <file> | compile --schema --json | witness migrate --plan <key>'
|
|
295
305
|
+ ' | witness scaffold --template --plan <key> [--json] | witness scaffold --schema --json | witness scaffold --plan <key> --input <draft>',
|
|
@@ -320,6 +330,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
320
330
|
'todo block': 'todo block --plan <key> --task <id> --reason <text>',
|
|
321
331
|
'todo unblock': 'todo unblock --plan <key> --task <id>',
|
|
322
332
|
'todo retire': 'todo retire --plan <key> --task <id> --reason <text>',
|
|
333
|
+
'todo add': 'todo add --plan <key> --task <id> --title <text> [--phase <id>] [--lane <lane>] [--done-condition <text>]'
|
|
334
|
+
+ ' [--design-memo <text>] [--after <id>[,<id>...]] [--before <id>[,<id>...]] [--reason <text>]',
|
|
323
335
|
'todo done': 'todo done --plan <key> --task <id> [--evidence <file>] [--message <text>] [--test-result <markdown-file>]',
|
|
324
336
|
'todo reopen': 'todo reopen --plan <key> --task <id> --reason <text> [--override-reason <text>]',
|
|
325
337
|
'todo evidence': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
package/src/plan-revise.mjs
CHANGED
|
@@ -412,14 +412,31 @@ export async function applyPlanRevision({
|
|
|
412
412
|
return result;
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
|
|
415
|
+
/** a39: `--plan` names the plan as every todo write does; it fills a missing plan_key and must match a written one. */
|
|
416
|
+
export function applyPlanFlag(input, planKey) {
|
|
417
|
+
if (planKey === undefined || !isRecord(input)) return input;
|
|
418
|
+
const wrapped = !isBareCreateInput(input) && isRecord(input.desired);
|
|
419
|
+
const target = wrapped ? input.desired : input;
|
|
420
|
+
if (target.plan_key === undefined) return wrapped ? { ...input, desired: { ...target, plan_key: planKey } }
|
|
421
|
+
: { ...input, plan_key: planKey };
|
|
422
|
+
if (target.plan_key !== planKey) {
|
|
423
|
+
fail('plan_revise_plan_key_mismatch', wrapped ? '/desired/plan_key' : '/plan_key', {
|
|
424
|
+
expected: planKey, actual: target.plan_key,
|
|
425
|
+
next_action: `--plan is "${planKey}" but the input revises "${target.plan_key}": make them the same, or drop --plan (the input's plan_key names the plan).`,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
return input;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export async function runPlanRevise({ cwd, inputRef, planKey, stdout, dryRun = false, env = process.env }) {
|
|
416
432
|
let repoRoot;
|
|
417
433
|
try {
|
|
418
434
|
repoRoot = path.resolve(gitSync(['rev-parse', '--show-toplevel'], {
|
|
419
435
|
cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
420
436
|
}).replace(/\r?\n$/u, ''));
|
|
421
437
|
} catch { throw new TodoStoreError('REPO_UNRESOLVED', 'git_toplevel_unresolved'); }
|
|
422
|
-
const input =
|
|
438
|
+
const input = applyPlanFlag(
|
|
439
|
+
await readAuthoringJsonFile(repoRoot, inputRef, { invalidCode: 'INPUT_INVALID' }), planKey);
|
|
423
440
|
const result = await applyPlanRevision({ repoRoot, input, env, dryRun });
|
|
424
441
|
stdout.write(`${JSON.stringify(result)}\n`);
|
|
425
442
|
return 0;
|
package/src/project-cli.mjs
CHANGED
|
@@ -1002,6 +1002,8 @@ export async function runPlanShow({ cwd, planKey, stdout }) {
|
|
|
1002
1002
|
phase_id: phaseInput ? task.phase_id : null,
|
|
1003
1003
|
state: stateByTaskId.get(task.task_id).status,
|
|
1004
1004
|
done_condition: task.done_condition ?? null,
|
|
1005
|
+
// a39: with design_memo, plan show holds every authored field a plan revise input needs.
|
|
1006
|
+
design_memo: task.design_memo ?? null,
|
|
1005
1007
|
depends_on_count: dependsOnCount.get(task.task_id) ?? 0,
|
|
1006
1008
|
}));
|
|
1007
1009
|
|
package/src/store-lock.mjs
CHANGED
|
@@ -11,6 +11,8 @@ const CLAIM = /^([0-9a-f]{64})-([1-9][0-9]*)-([0-9a-f]{64})-([0-9a-f]{16})$/u;
|
|
|
11
11
|
// its heartbeat mtime is older than LOCK_STALE_MS; every holder touches its lock and claim.
|
|
12
12
|
export const LOCK_STALE_MS = 10 * 60_000;
|
|
13
13
|
export const LOCK_HEARTBEAT_MS = 30_000;
|
|
14
|
+
// Several seats share one store: a writer waits out another live process this long, then refuses.
|
|
15
|
+
export const LOCK_WAIT_MS = 30_000;
|
|
14
16
|
// Weak identity when own observation is unavailable: never PID-recovered, only heartbeat-stale.
|
|
15
17
|
const WEAK = 'unobserved';
|
|
16
18
|
const NO_HARD_LINK = ['EPERM', 'ENOTSUP', 'EOPNOTSUPP', 'EXDEV', 'ENOSYS'];
|
|
@@ -167,10 +169,12 @@ async function recoveryClaim(claimsPath, owner, lockPath) {
|
|
|
167
169
|
// Timestamp ordering could let a delayed earlier publisher enter twice.
|
|
168
170
|
const candidates = await readdir(claimsPath);
|
|
169
171
|
if (candidates.length === 1 && candidates[0] === name) return claimPath;
|
|
170
|
-
|
|
172
|
+
const contended = new StoreLockError('store_locked', lockPath, {
|
|
171
173
|
recovery_claims_path: claimsPath,
|
|
172
174
|
next_action: `Retry after recovery claimants exit; for foreign or unidentified claims, confirm no writer on their recorded host before clearing only abandoned entries in ${claimsPath}`,
|
|
173
175
|
});
|
|
176
|
+
contended.contended = true;
|
|
177
|
+
throw contended;
|
|
174
178
|
} catch (error) {
|
|
175
179
|
await rmdir(claimPath);
|
|
176
180
|
throw error;
|
|
@@ -206,7 +210,7 @@ async function removeClaim(claimPath, claimsPath) {
|
|
|
206
210
|
|
|
207
211
|
/** Complete ownership is linked atomically; recovery never removes a live owner. */
|
|
208
212
|
export async function withStoreLock({ lockPath, recoveryClaimsPath = `${lockPath}.recovery`,
|
|
209
|
-
onRecoveryClaim = null, createParent = true, releasePath = () => lockPath }, callback) {
|
|
213
|
+
onRecoveryClaim = null, createParent = true, releasePath = () => lockPath, waitMs = 0 }, callback) {
|
|
210
214
|
if (createParent) await mkdir(path.dirname(lockPath), { recursive: true });
|
|
211
215
|
ownStart ??= observeStartIdentityRaw(process.pid).catch((error) => { ownStart = undefined; throw error; });
|
|
212
216
|
ownHost ??= observeProcessHostIdentityRaw().then((value) => {
|
|
@@ -259,6 +263,8 @@ export async function withStoreLock({ lockPath, recoveryClaimsPath = `${lockPath
|
|
|
259
263
|
fileIdentity = await handle.stat();
|
|
260
264
|
}
|
|
261
265
|
finally { await handle.close(); }
|
|
266
|
+
const deadline = Date.now() + waitMs;
|
|
267
|
+
let pause = 10;
|
|
262
268
|
for (;;) {
|
|
263
269
|
try { await link(temporary, lockPath); acquired = true; break; }
|
|
264
270
|
catch (error) {
|
|
@@ -279,14 +285,33 @@ export async function withStoreLock({ lockPath, recoveryClaimsPath = `${lockPath
|
|
|
279
285
|
}
|
|
280
286
|
const existing = await readOwner(lockPath);
|
|
281
287
|
if (existing === null) continue;
|
|
282
|
-
|
|
288
|
+
const backOff = async (refusal) => {
|
|
289
|
+
if (Date.now() >= deadline) throw refusal;
|
|
290
|
+
await new Promise((resolve) => { setTimeout(resolve, pause + Math.random() * pause); });
|
|
291
|
+
pause = Math.min(pause * 2, 250);
|
|
292
|
+
};
|
|
293
|
+
// A live owner is waited out until the deadline. Our own PID (re-entry) would wait on
|
|
294
|
+
// ourselves, and an unidentified owner keeps its refusal, so both refuse at once.
|
|
295
|
+
const waitFor = async (live) => {
|
|
296
|
+
const self = live.owner?.pid === process.pid && live.owner?.host === host;
|
|
297
|
+
if (live.owner === null || self) throw busy(live, lockPath);
|
|
298
|
+
await backOff(busy(live, lockPath));
|
|
299
|
+
};
|
|
300
|
+
if (!await abandoned(existing, host)) { await waitFor(existing); continue; }
|
|
283
301
|
if (claimPath === null) {
|
|
284
|
-
claimPath = await recoveryClaim(recoveryClaimsPath, owner, lockPath);
|
|
302
|
+
try { claimPath = await recoveryClaim(recoveryClaimsPath, owner, lockPath); }
|
|
303
|
+
catch (error) {
|
|
304
|
+
// Several writers judged the same just-exited owner at once; none is sole, so all back off.
|
|
305
|
+
if (error?.contended !== true) throw error;
|
|
306
|
+
await backOff(error);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
285
309
|
if (onRecoveryClaim) await onRecoveryClaim();
|
|
286
310
|
}
|
|
287
311
|
const fresh = await readOwner(lockPath);
|
|
288
312
|
if (fresh !== null) {
|
|
289
|
-
|
|
313
|
+
// The judged owner released and a new live writer linked in meanwhile.
|
|
314
|
+
if (!await abandoned(fresh, host)) { await waitFor(fresh); continue; }
|
|
290
315
|
await removeJudged(lockPath, fresh.info);
|
|
291
316
|
}
|
|
292
317
|
}
|
package/src/todo-cli.mjs
CHANGED
|
@@ -87,6 +87,8 @@ import {
|
|
|
87
87
|
readTodoWitnessSet,
|
|
88
88
|
todoWitnessRef,
|
|
89
89
|
writeTodoWitnessSet,
|
|
90
|
+
readTodoStoreDisplaySource,
|
|
91
|
+
readTodoStoreForDisplay,
|
|
90
92
|
readTodoStoreStable,
|
|
91
93
|
rebuildTodoSnapshot,
|
|
92
94
|
writeTodoIndependenceArtifact,
|
|
@@ -287,10 +289,10 @@ function internalFailure(stderr, error) {
|
|
|
287
289
|
}
|
|
288
290
|
|
|
289
291
|
const TODO_COMMAND_NAMES = Object.freeze([
|
|
290
|
-
'status', 'show', 'note', 'bindings', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
292
|
+
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
291
293
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
292
294
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
293
|
-
'retract', 'dependency',
|
|
295
|
+
'retract', 'dependency', 'add',
|
|
294
296
|
]);
|
|
295
297
|
|
|
296
298
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -328,6 +330,10 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
328
330
|
unblock: Object.freeze({ known: ['plan', 'task'], required: ['plan', 'task'] }),
|
|
329
331
|
reopen: Object.freeze({ known: ['plan', 'task', 'reason', 'override-reason'], required: ['plan', 'task', 'reason'] }),
|
|
330
332
|
'dependency connect': DEPENDENCY_FLAG_SPEC,
|
|
333
|
+
add: Object.freeze({
|
|
334
|
+
known: ['plan', 'task', 'title', 'phase', 'lane', 'done-condition', 'design-memo', 'after', 'before', 'reason'],
|
|
335
|
+
required: ['plan', 'task', 'title'],
|
|
336
|
+
}),
|
|
331
337
|
'dependency disconnect': DEPENDENCY_FLAG_SPEC,
|
|
332
338
|
// a23: the remaining writes whose refusal pointed only at --help.
|
|
333
339
|
'phase review': PHASE_REASON_FLAG_SPEC,
|
|
@@ -1651,6 +1657,61 @@ async function dependencyRevision({
|
|
|
1651
1657
|
return result;
|
|
1652
1658
|
}
|
|
1653
1659
|
|
|
1660
|
+
/**
|
|
1661
|
+
* a39: 1件のtaskを、planを書き直さずに足す。dependency connectと同じ軽量改訂の道で、
|
|
1662
|
+
* 現行planから作ったdesiredへtaskと辺(after→新task、新task→before)を足して適用する。
|
|
1663
|
+
*/
|
|
1664
|
+
async function addTask({ repoRoot, env, planKey, flags }) {
|
|
1665
|
+
const { applyPlanRevision, desiredFromPlan } = await import('./plan-revise.mjs');
|
|
1666
|
+
const store = await readTodoStore({ repoRoot });
|
|
1667
|
+
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
1668
|
+
if (member === undefined) {
|
|
1669
|
+
throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
1670
|
+
}
|
|
1671
|
+
const taskId = flags.task;
|
|
1672
|
+
const known = new Set(member.plan.tasks.map(({ task_id: id }) => id));
|
|
1673
|
+
if (known.has(taskId)) {
|
|
1674
|
+
throw new TodoStoreError('INPUT_INVALID', 'todo_add_task_exists', undefined, {
|
|
1675
|
+
plan_key: planKey, task_id: taskId, pointer: '--task',
|
|
1676
|
+
next_action: `${planKey}/${taskId} already exists: pick an unused --task id (see \`lattice plan show ${planKey} --json\`), or change the task with \`lattice plan revise --input <file>\`.`,
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
const ids = (value) => (typeof value === 'string' ? value.split(',').map((id) => id.trim()).filter(Boolean) : []);
|
|
1680
|
+
const after = ids(flags.after);
|
|
1681
|
+
const before = ids(flags.before);
|
|
1682
|
+
for (const id of [...after, ...before]) {
|
|
1683
|
+
if (!known.has(id)) {
|
|
1684
|
+
throw new TodoStoreError('DEPENDENCY_INVALID', 'dependency_task_not_found', undefined, {
|
|
1685
|
+
ref: dependencyRef(store, planKey, id),
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
const task = { task_id: taskId, title: flags.title };
|
|
1690
|
+
for (const [flag, field] of [['phase', 'phase_id'], ['lane', 'lane'],
|
|
1691
|
+
['done-condition', 'done_condition'], ['design-memo', 'design_memo']]) {
|
|
1692
|
+
if (typeof flags[flag] === 'string') task[field] = flags[flag];
|
|
1693
|
+
}
|
|
1694
|
+
const desired = desiredFromPlan(member.plan, { env });
|
|
1695
|
+
const ref = (id) => dependencyRef(store, planKey, id);
|
|
1696
|
+
desired.tasks = [...desired.tasks, task];
|
|
1697
|
+
desired.hard_dependencies = [...desired.hard_dependencies,
|
|
1698
|
+
...after.map((id) => ({ from: ref(id), to: ref(taskId) })),
|
|
1699
|
+
...before.map((id) => ({ from: ref(taskId), to: ref(id) }))];
|
|
1700
|
+
const reason = typeof flags.reason === 'string' ? flags.reason : null;
|
|
1701
|
+
const applied = await applyPlanRevision({
|
|
1702
|
+
repoRoot, env, input: { schema: 'lattice.plan_revise_input.v1', desired },
|
|
1703
|
+
notes: [{ task_id: taskId, body: `todo add ${taskId}${reason === null ? '' : `: ${reason}`}` }],
|
|
1704
|
+
});
|
|
1705
|
+
const result = {
|
|
1706
|
+
schema: 'lattice.todo_task_add_result.v1', project_id: store.project_id, plan_key: planKey,
|
|
1707
|
+
task_id: taskId, after, before, reason, actor: desired.actor,
|
|
1708
|
+
plan_version: applied.plan_version, revision_digest: applied.revision?.revision_digest ?? null,
|
|
1709
|
+
rebound_task_ids: applied.rebound_task_ids, result_digest: '',
|
|
1710
|
+
};
|
|
1711
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
1712
|
+
return result;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1654
1715
|
const samePlanEdge = (member, fromTaskId, toTaskId) => member.plan.hard_dependencies.some((edge) => (
|
|
1655
1716
|
edge.from.task_id === fromTaskId && edge.to.task_id === toTaskId));
|
|
1656
1717
|
|
|
@@ -4633,6 +4694,12 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4633
4694
|
&& argv[1] === '--plan' && isTodoIdentifier(argv[2])
|
|
4634
4695
|
&& (argv.length === 3 || argv[3] === '--json')) {
|
|
4635
4696
|
action = (repoRoot) => bindings({ repoRoot, requestedPlanKey: argv[2] });
|
|
4697
|
+
} else if (argv[0] === 'display' && (argv[1] === 'read' || argv[1] === 'source')
|
|
4698
|
+
&& (argv.length === 2 || (argv.length === 3 && argv[2] === '--json'))) {
|
|
4699
|
+
// Host display read (BellTeam module): a typed inconsistency is a state, never a refusal.
|
|
4700
|
+
action = argv[1] === 'read'
|
|
4701
|
+
? async (repoRoot) => ({ schema: 'lattice.todo_display_read_result.v1', ...await readTodoStoreForDisplay({ repoRoot }) })
|
|
4702
|
+
: (repoRoot) => readTodoStoreDisplaySource({ repoRoot });
|
|
4636
4703
|
} else if (argv[0] === 'note' && argv[1] !== 'list') {
|
|
4637
4704
|
const flags = matchFlagCommand(argv, ['note'], NOTE_FLAG_SPEC);
|
|
4638
4705
|
const hasMessage = typeof flags?.message === 'string' && flags.message.length > 0;
|
|
@@ -4927,6 +4994,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4927
4994
|
kind: 'block', payload: { reason: flags.reason }, evidenceRef: null,
|
|
4928
4995
|
}) });
|
|
4929
4996
|
}
|
|
4997
|
+
} else if (argv[0] === 'add') {
|
|
4998
|
+
const flags = matchFlagCommand(argv, ['add'], TODO_FLAG_SPECS.add);
|
|
4999
|
+
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
5000
|
+
action = (repoRoot) => addTask({ repoRoot, env, planKey: flags.plan, flags });
|
|
5001
|
+
}
|
|
4930
5002
|
} else if (argv[0] === 'retire') {
|
|
4931
5003
|
// 恒久除去(2026-08-29オーナー裁定)。planの形は変えず、状態遷移として工程を閉じる。
|
|
4932
5004
|
const flags = matchFlagCommand(argv, ['retire'], TODO_FLAG_SPECS.retire);
|
package/src/todo-note-store.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
lstat, mkdir, open, readFile, readdir, rename, rm, stat,
|
|
5
5
|
} from 'node:fs/promises';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
-
import { StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
7
|
+
import { LOCK_WAIT_MS, StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
8
8
|
import { syncPublishedFile } from './fs-publish.mjs';
|
|
9
9
|
import { normalizeCheckoutEol } from './todo-store-view.mjs';
|
|
10
10
|
|
|
@@ -236,7 +236,7 @@ async function withNoteLock(repoRoot, callback) {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
await ensureNoteDirectory(root);
|
|
239
|
-
return await withStoreLock({ lockPath: path.join(root, '.write.lock'), createParent: false }, callback);
|
|
239
|
+
return await withStoreLock({ lockPath: path.join(root, '.write.lock'), createParent: false, waitMs: LOCK_WAIT_MS }, callback);
|
|
240
240
|
}
|
|
241
241
|
catch (error) {
|
|
242
242
|
if (error instanceof StoreLockError) {
|
package/src/todo-store.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export {
|
|
|
17
17
|
import { randomBytes } from 'node:crypto';
|
|
18
18
|
import { fsyncDirectory } from './fs-dir-sync.mjs';
|
|
19
19
|
import { renamePublishedFile, syncPublishedFile } from './fs-publish.mjs';
|
|
20
|
-
import { StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
20
|
+
import { LOCK_WAIT_MS, StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
21
21
|
import {
|
|
22
22
|
lstat, mkdir, open, readFile, readdir, realpath, rename, rm, rmdir,
|
|
23
23
|
} from 'node:fs/promises';
|
|
@@ -2122,6 +2122,7 @@ async function withLock(repoRoot, callback, {
|
|
|
2122
2122
|
return await withStoreLock({
|
|
2123
2123
|
lockPath: path.join(repoRoot, STORE_ROOT_REF, '.write.lock'),
|
|
2124
2124
|
createParent: initialize,
|
|
2125
|
+
waitMs: LOCK_WAIT_MS,
|
|
2125
2126
|
recoveryClaimsPath: path.join(repoRoot, CROSS_PLAN_RECOVERY_CLAIMS_REF),
|
|
2126
2127
|
onRecoveryClaim: typeof onProtocolStage === 'function'
|
|
2127
2128
|
? () => onProtocolStage('cross_plan_lock_recovery_mutex_acquired') : null,
|