@quolu/lattice 0.84.2 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -1
- package/bin/lattice.mjs +11 -2
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +1 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +1 -3
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +1 -1
- package/docs/schemas/lattice.todo_extraction.v3.schema.json +1 -1
- package/docs/schemas/lattice.todo_extraction.v4.schema.json +1 -1
- package/package.json +1 -1
- package/src/cli-help.mjs +7 -5
- package/src/cli-refusal-guidance.mjs +31 -3
- package/src/hooks-cli.mjs +6 -1
- package/src/plan-backchain.mjs +21 -3
- package/src/plan-revise.mjs +13 -4
- package/src/project-cli.mjs +42 -19
- package/src/runtime-pull-intake.mjs +2 -2
- package/src/seam-proposal-contracts.mjs +2 -1
- package/src/setup-cli.mjs +1 -0
- package/src/todo-authoring-input.mjs +13 -3
- package/src/todo-cli.mjs +198 -79
- package/src/todo-independence-contracts.mjs +4 -1
- package/src/todo-independence-guidance.mjs +43 -38
- package/src/todo-store.mjs +14 -4
package/src/todo-cli.mjs
CHANGED
|
@@ -275,6 +275,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
275
275
|
'status', 'show', 'note', 'bindings', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
276
276
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
277
277
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
278
|
+
'retract', 'dependency',
|
|
278
279
|
]);
|
|
279
280
|
|
|
280
281
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -291,15 +292,74 @@ const DONE_FLAG_SPEC = Object.freeze({
|
|
|
291
292
|
required: ['plan', 'task'],
|
|
292
293
|
});
|
|
293
294
|
|
|
294
|
-
|
|
295
|
+
const REASON_FLAG_SPEC = Object.freeze({ known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'] });
|
|
296
|
+
const DEPENDENCY_FLAG_SPEC = Object.freeze({
|
|
297
|
+
known: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
298
|
+
required: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
299
|
+
});
|
|
300
|
+
// a18: one spec per write command is both its parser and the explanation of its refusal.
|
|
301
|
+
const TODO_FLAG_SPECS = Object.freeze({
|
|
302
|
+
start: Object.freeze({
|
|
303
|
+
known: ['plan', 'task', 'parallel-frontier', 'override-reason', 'serial-confirmed', 'rebind', 'reason'],
|
|
304
|
+
required: ['plan', 'task'],
|
|
305
|
+
booleans: ['parallel-frontier', 'serial-confirmed', 'rebind'],
|
|
306
|
+
}),
|
|
307
|
+
done: DONE_FLAG_SPEC,
|
|
308
|
+
block: REASON_FLAG_SPEC,
|
|
309
|
+
retire: REASON_FLAG_SPEC,
|
|
310
|
+
retract: REASON_FLAG_SPEC,
|
|
311
|
+
unblock: Object.freeze({ known: ['plan', 'task'], required: ['plan', 'task'] }),
|
|
312
|
+
reopen: Object.freeze({ known: ['plan', 'task', 'reason', 'override-reason'], required: ['plan', 'task', 'reason'] }),
|
|
313
|
+
'dependency connect': DEPENDENCY_FLAG_SPEC,
|
|
314
|
+
'dependency disconnect': DEPENDENCY_FLAG_SPEC,
|
|
315
|
+
});
|
|
316
|
+
const IDENTIFIER_FLAGS = ['plan', 'task', 'from-plan', 'from-task', 'to-plan', 'to-task'];
|
|
317
|
+
const FLAG_PLACEHOLDER = { reason: '<text>', 'override-reason': '<text>', message: '<text>',
|
|
318
|
+
evidence: '<file>', 'test-result': '<file>' };
|
|
319
|
+
const shellWord = (value) => (/^[\w./:@-]+$/u.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`);
|
|
320
|
+
|
|
321
|
+
/** The command again, with the flags given and a placeholder for each missing required flag. */
|
|
322
|
+
function repairedCommand(head, spec, flags) {
|
|
323
|
+
const words = ['lattice', 'todo', ...head];
|
|
324
|
+
for (const name of spec.known) {
|
|
325
|
+
if (typeof flags[name] === 'string' && flags[name].length > 0) words.push(`--${name}`, shellWord(flags[name]));
|
|
326
|
+
else if (flags[name] === true && spec.booleans?.includes(name)) words.push(`--${name}`);
|
|
327
|
+
else if (spec.required.includes(name)) words.push(`--${name}`, FLAG_PLACEHOLDER[name] ?? `<${name}>`);
|
|
328
|
+
}
|
|
329
|
+
return words.join(' ');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** `dependency connect|disconnect` flags by name (order-free), or null. */
|
|
333
|
+
function dependencyFlags(argv) {
|
|
334
|
+
const flags = matchFlagCommand(argv, argv.slice(0, 2), DEPENDENCY_FLAG_SPEC);
|
|
335
|
+
return flags !== null && IDENTIFIER_FLAGS.slice(2).every((name) => isTodoIdentifier(flags[name])) ? flags : null;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** A todo write's argument refusal names the flag, the rule and the command to run instead. */
|
|
295
339
|
function explainArgumentRefusal(argv) {
|
|
296
|
-
|
|
297
|
-
const
|
|
340
|
+
const head = argv[0] === 'dependency' ? argv.slice(0, 2) : argv.slice(0, 1);
|
|
341
|
+
const spec = TODO_FLAG_SPECS[head.join(' ')];
|
|
342
|
+
if (spec === undefined) return {};
|
|
343
|
+
const { flags } = parseFlagMap(argv.slice(head.length));
|
|
344
|
+
const flagFailure = explainFlagCommand(argv, head, spec);
|
|
345
|
+
if (flagFailure?.rule === 'flag_missing') {
|
|
346
|
+
return { ...flagFailure, next_action: `Add ${flagFailure.pointer} ${FLAG_PLACEHOLDER[flagFailure.pointer.slice(2)] ?? '<value>'}: \`${repairedCommand(head, spec, flags)}\`.` };
|
|
347
|
+
}
|
|
298
348
|
if (flagFailure !== null) return flagFailure;
|
|
299
|
-
const
|
|
300
|
-
for (const name of ['plan', 'task']) {
|
|
349
|
+
for (const name of IDENTIFIER_FLAGS.filter((key) => spec.known.includes(key))) {
|
|
301
350
|
if (!isTodoIdentifier(flags[name])) return { pointer: `--${name}`, rule: 'identifier_invalid', actual: flags[name] };
|
|
302
351
|
}
|
|
352
|
+
for (const name of ['override-reason', 'reason']) {
|
|
353
|
+
if (spec.known.includes(name) && flags[name] !== undefined
|
|
354
|
+
&& !(typeof flags[name] === 'string' && flags[name].length > 0)) {
|
|
355
|
+
return { pointer: `--${name}`, rule: 'flag_missing', next_action: `Give --${name} a non-empty <text>: \`${repairedCommand(head, spec, flags)}\`.` };
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (argv[0] === 'start' && flags.rebind === true && !(typeof flags.reason === 'string' && flags.reason.length > 0)) {
|
|
359
|
+
return { pointer: '--reason', rule: 'flag_missing',
|
|
360
|
+
next_action: `--rebind needs --reason <text>: \`${repairedCommand(head, { ...spec, required: [...spec.required, 'reason'] }, flags)}\`.` };
|
|
361
|
+
}
|
|
362
|
+
if (argv[0] !== 'done') return {};
|
|
303
363
|
const hasMessage = typeof flags.message === 'string' && flags.message.length > 0;
|
|
304
364
|
if (flags.message !== undefined && !hasMessage) return { pointer: '--message', rule: 'flag_missing' };
|
|
305
365
|
if (flags.evidence !== undefined && !isAuthoringPathToken(flags.evidence)) {
|
|
@@ -699,9 +759,9 @@ function reopenAdvisory(plan, phases, taskId) {
|
|
|
699
759
|
async function mutate({
|
|
700
760
|
repoRoot, env, planKey, taskId, kind, payload, evidenceRef, evidenceMessage = null,
|
|
701
761
|
advisory = null, noteContext = null, structureContext = null, featureContext = null,
|
|
702
|
-
testResultRef = null,
|
|
762
|
+
testResultRef = null, actor: carriedActor = null,
|
|
703
763
|
}) {
|
|
704
|
-
const actor = resolveTodoActor(env);
|
|
764
|
+
const actor = carriedActor ?? resolveTodoActor(env);
|
|
705
765
|
const evidence = evidenceRef === null && evidenceMessage === null
|
|
706
766
|
? null
|
|
707
767
|
: await resolveDoneEvidence({
|
|
@@ -792,7 +852,7 @@ const UNCHANGED_WHEN = {
|
|
|
792
852
|
};
|
|
793
853
|
|
|
794
854
|
/** Unchanged result, or null when the transition must go to the append path. */
|
|
795
|
-
function unchangedTransition(store, { env, planKey, taskId, kind }) {
|
|
855
|
+
function unchangedTransition(store, { env, planKey, taskId, kind, notRecorded = [] }) {
|
|
796
856
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
797
857
|
const matches = member?.tasks.filter(({ task_id: current }) => current.toLowerCase() === taskId.toLowerCase()) ?? [];
|
|
798
858
|
// Unknown or ambiguous plan/task: the append path keeps Store's refusal.
|
|
@@ -808,7 +868,15 @@ function unchangedTransition(store, { env, planKey, taskId, kind }) {
|
|
|
808
868
|
project_id: member.plan.project_id, plan_key: planKey, plan_version: member.plan.plan_version,
|
|
809
869
|
task_id: state.task_id, kind, sequence: shown.sequence, event_digest: shown.event_digest,
|
|
810
870
|
journal_head_digest: events.at(-1).event_digest, snapshot_digest: member.snapshot.snapshot_digest,
|
|
811
|
-
status: state.status, advisory: null, unchanged: true,
|
|
871
|
+
status: state.status, advisory: null, unchanged: true,
|
|
872
|
+
// a18: a repeated done appends nothing, so say which given content was not recorded.
|
|
873
|
+
...(notRecorded.length === 0 ? {} : {
|
|
874
|
+
not_recorded: notRecorded,
|
|
875
|
+
next_action: `${planKey}/${state.task_id} was already done; ${notRecorded.join(', ')} not recorded.`
|
|
876
|
+
+ ` Keep the text with \`lattice todo note --plan ${planKey} --task ${state.task_id} --message <text>\`,`
|
|
877
|
+
+ ` or replace the record: \`lattice todo reopen --plan ${planKey} --task ${state.task_id} --reason <text>\`, then start and done again.`,
|
|
878
|
+
}),
|
|
879
|
+
result_digest: '',
|
|
812
880
|
};
|
|
813
881
|
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
814
882
|
return result;
|
|
@@ -820,6 +888,26 @@ async function mutateUnlessUnchanged(options) {
|
|
|
820
888
|
return unchangedTransition(store, options) ?? options.action();
|
|
821
889
|
}
|
|
822
890
|
|
|
891
|
+
/** a18: the live tasks with an edge (plan, join or ledger) from the task being retired, sorted. */
|
|
892
|
+
function retireDependents(store, member, taskId) {
|
|
893
|
+
const planKey = member.plan.plan_key;
|
|
894
|
+
const fromIt = (ref) => ref.plan_key === planKey && ref.task_id === taskId;
|
|
895
|
+
const targets = [
|
|
896
|
+
...member.plan.hard_dependencies.filter((edge) => fromIt(edge.from)).map((edge) => edge.to),
|
|
897
|
+
...member.plan.joins.filter((join) => join.after.some(fromIt)).map((join) => join.before),
|
|
898
|
+
...projectTodoCrossPlanDependencies(store.members).filter((edge) => fromIt(edge.from)).map((edge) => edge.to),
|
|
899
|
+
];
|
|
900
|
+
const byKey = new Map();
|
|
901
|
+
for (const ref of targets) {
|
|
902
|
+
const status = store.members.find(({ plan }) => plan.plan_key === ref.plan_key)
|
|
903
|
+
?.tasks.find(({ task_id: id }) => id === ref.task_id)?.status;
|
|
904
|
+
if (status !== undefined && status !== 'retired') {
|
|
905
|
+
byKey.set(`${ref.plan_key}\0${ref.task_id}`, { plan_key: ref.plan_key, task_id: ref.task_id, status });
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return [...byKey.entries()].sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0)).map(([, task]) => task);
|
|
909
|
+
}
|
|
910
|
+
|
|
823
911
|
async function retireTask({ repoRoot, env, planKey, taskId, reason }) {
|
|
824
912
|
const store = await readTodoStore({ repoRoot });
|
|
825
913
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
@@ -829,13 +917,22 @@ async function retireTask({ repoRoot, env, planKey, taskId, reason }) {
|
|
|
829
917
|
return mutate({ repoRoot, env, planKey, taskId, kind: 'retire', payload: { reason }, evidenceRef: null });
|
|
830
918
|
}
|
|
831
919
|
if (state.status === 'retired') return unchangedTransition(store, { env, planKey, taskId, kind: 'retire' });
|
|
920
|
+
const dependents = retireDependents(store, member, taskId);
|
|
832
921
|
const append = async () => {
|
|
922
|
+
let result;
|
|
833
923
|
try {
|
|
834
|
-
|
|
924
|
+
result = await mutate({ repoRoot, env, planKey, taskId, kind: 'retire',
|
|
835
925
|
payload: { reason, prior_status: state.status }, evidenceRef: null });
|
|
836
926
|
} catch (error) {
|
|
837
927
|
throw retireStateConflict(error, { planKey, taskId, priorStatus: state.status });
|
|
838
928
|
}
|
|
929
|
+
const { result_digest: _replaced, ...recorded } = result;
|
|
930
|
+
const named = { ...recorded, dependents, ...(dependents.length === 0 ? {} : {
|
|
931
|
+
next_action: `${dependents.map((task) => `${task.plan_key}/${task.task_id} (${task.status})`).join(', ')}`
|
|
932
|
+
+ ` no longer wait on ${planKey}/${taskId}; see \`lattice todo status --json\`.`,
|
|
933
|
+
}), result_digest: '' };
|
|
934
|
+
named.result_digest = todoSelfDigest(named, 'result_digest');
|
|
935
|
+
return named;
|
|
839
936
|
};
|
|
840
937
|
if (state.status !== 'in-progress') return append();
|
|
841
938
|
// Runtime binds an intake to the latest literal start and ignores later done/reopen, so the
|
|
@@ -938,7 +1035,7 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
938
1035
|
.filter((task) => task.plan_key === planKey).map(({ task_id: id }) => id),
|
|
939
1036
|
self_unknowns: [{ kind: 'witness_missing', ref: unusable ?? 'no_independence_record' }],
|
|
940
1037
|
guidance: selectIndependenceGuidance({
|
|
941
|
-
coverage: 'missing', taskDeclared: false, taskStale: false, coordinationMode,
|
|
1038
|
+
coverage: 'missing', taskDeclared: false, taskStale: false, coordinationMode, planKey,
|
|
942
1039
|
}),
|
|
943
1040
|
};
|
|
944
1041
|
}
|
|
@@ -987,7 +1084,7 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
987
1084
|
conflictWithActive: conflictsWithActive[0]?.severability ?? null,
|
|
988
1085
|
conflictBetweenReady: readyConflict?.severability ?? null,
|
|
989
1086
|
verdictsAbsent: selfUnknowns.some(({ kind }) => kind === 'plan_verdicts_absent'),
|
|
990
|
-
coordinationMode,
|
|
1087
|
+
coordinationMode, planKey,
|
|
991
1088
|
}),
|
|
992
1089
|
};
|
|
993
1090
|
}
|
|
@@ -1069,7 +1166,8 @@ async function startTask({
|
|
|
1069
1166
|
// literal startだけを束縛に使いcarryを推定しないため、改訂を跨いだ進行中工程の
|
|
1070
1167
|
// 再開はこの入口だけが正規経路になる。advisory・independence gateは初回startで
|
|
1071
1168
|
// 済んでいるため再適用しない。
|
|
1072
|
-
|
|
1169
|
+
// actor: 改訂が運ぶstartの記録者。渡せば現在の席でなくその記録者でrebind startを積む(a16)。
|
|
1170
|
+
export async function rebindStart({ repoRoot, env, planKey, taskId, reason, actor = null }) {
|
|
1073
1171
|
const store = await readTodoStore({ repoRoot });
|
|
1074
1172
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
1075
1173
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active');
|
|
@@ -1101,7 +1199,7 @@ export async function rebindStart({ repoRoot, env, planKey, taskId, reason }) {
|
|
|
1101
1199
|
}
|
|
1102
1200
|
return mutate({
|
|
1103
1201
|
repoRoot, env, planKey, taskId, kind: 'start',
|
|
1104
|
-
payload: { start_mode: 'rebind', reason }, evidenceRef: null, noteContext,
|
|
1202
|
+
payload: { start_mode: 'rebind', reason }, evidenceRef: null, noteContext, actor,
|
|
1105
1203
|
});
|
|
1106
1204
|
}
|
|
1107
1205
|
|
|
@@ -1290,11 +1388,21 @@ async function dependencyRevision({
|
|
|
1290
1388
|
? [...desired.hard_dependencies, { from, to }]
|
|
1291
1389
|
: desired.hard_dependencies.filter((edge) => !(edge.from.task_id === fromTaskId
|
|
1292
1390
|
&& edge.to.task_id === toTaskId));
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1391
|
+
let applied;
|
|
1392
|
+
try {
|
|
1393
|
+
applied = await applyPlanRevision({
|
|
1394
|
+
repoRoot, env, input: { schema: 'lattice.plan_revise_input.v1', desired },
|
|
1395
|
+
notes: [{ task_id: fromTaskId,
|
|
1396
|
+
body: `dependency ${operation} ${fromTaskId}→${toTaskId}: ${reason}` }],
|
|
1397
|
+
});
|
|
1398
|
+
} catch (error) {
|
|
1399
|
+
// a18: the new edge closes a cycle; nothing stored is inconsistent, so name the edge and the path.
|
|
1400
|
+
if (operation === 'connect' && error instanceof TodoStoreError && error.detail?.reason === 'merged_cycle') {
|
|
1401
|
+
throw new TodoStoreError('DEPENDENCY_CYCLE', 'dependency_cycle', undefined, {
|
|
1402
|
+
from, to, cycle: error.detail.cycle ?? null });
|
|
1403
|
+
}
|
|
1404
|
+
throw error;
|
|
1405
|
+
}
|
|
1298
1406
|
const result = {
|
|
1299
1407
|
schema: 'lattice.todo_dependency_revision_result.v1', project_id: store.project_id,
|
|
1300
1408
|
plan_key: planKey, operation, from, to, reason, actor: desired.actor,
|
|
@@ -1421,11 +1529,20 @@ async function dependencyDisconnectLedger({
|
|
|
1421
1529
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId
|
|
1422
1530
|
));
|
|
1423
1531
|
if (live.length === 0) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1532
|
+
const from = { plan_key: fromPlanKey, task_id: fromTaskId };
|
|
1533
|
+
const to = { plan_key: toPlanKey, task_id: toTaskId };
|
|
1534
|
+
if (fromPlanKey === toPlanKey) {
|
|
1535
|
+
const member = store.members.find(({ plan }) => plan.plan_key === toPlanKey);
|
|
1536
|
+
const predecessors = (member?.plan.hard_dependencies ?? [])
|
|
1537
|
+
.filter((edge) => edge.to.task_id === toTaskId).map((edge) => edge.from.task_id).sort();
|
|
1538
|
+
throw new TodoStoreError('DEPENDENCY_NOT_FOUND', 'dependency_not_found', undefined, {
|
|
1539
|
+
from, to, predecessors,
|
|
1540
|
+
next_action: `${toPlanKey} has no dependency ${fromTaskId} -> ${toTaskId}`
|
|
1541
|
+
+ ` (${toTaskId} depends on ${predecessors.length === 0 ? 'nothing in this plan' : predecessors.join(', ')});`
|
|
1542
|
+
+ ` see \`lattice plan show ${toPlanKey} --json\`.`,
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
throw new TodoStoreError('DEPENDENCY_NOT_FOUND', 'cross_plan_dependency_not_found', undefined, { from, to });
|
|
1429
1546
|
}
|
|
1430
1547
|
const [target] = live;
|
|
1431
1548
|
const owner = store.members.find((member) => (member.plan_scoped?.events ?? [])
|
|
@@ -2867,7 +2984,7 @@ async function independenceCompile({ repoRoot, planKey, inputRef }) {
|
|
|
2867
2984
|
{
|
|
2868
2985
|
plan_key: planKey,
|
|
2869
2986
|
missing_task_ids: missingReady,
|
|
2870
|
-
next_action:
|
|
2987
|
+
next_action: independenceCompileCommand(planKey),
|
|
2871
2988
|
},
|
|
2872
2989
|
);
|
|
2873
2990
|
}
|
|
@@ -3035,7 +3152,7 @@ async function independence({ repoRoot, requestedPlanKey }) {
|
|
|
3035
3152
|
conflictBetweenReady: projected.frontier.serialize_pairs[0]?.severability ?? null,
|
|
3036
3153
|
// 案内の正本は1つ(ADR 0130 Decision 1)。着手する人と読みに来た人が同じ状況について
|
|
3037
3154
|
// 違う文言を受け取らないよう、調整方式もここへ渡す。
|
|
3038
|
-
coordinationMode: member?.coordination?.mode ?? null,
|
|
3155
|
+
coordinationMode: member?.coordination?.mode ?? null, planKey,
|
|
3039
3156
|
verdictsAbsent: projected.frontier.unknown
|
|
3040
3157
|
.some(({ unknowns }) => unknowns.some(({ kind }) => kind === 'plan_verdicts_absent')),
|
|
3041
3158
|
}),
|
|
@@ -3099,6 +3216,8 @@ async function seamProfile({ repoRoot, planKey, filePath }) {
|
|
|
3099
3216
|
return profile;
|
|
3100
3217
|
}
|
|
3101
3218
|
|
|
3219
|
+
const independenceCompileCommand = (planKey, input = '<file>') => `lattice todo independence compile --plan ${planKey} --input ${input}`;
|
|
3220
|
+
|
|
3102
3221
|
async function seamProposalCompile({ repoRoot, planKey }) {
|
|
3103
3222
|
const currentBaseSha = currentHeadSha(repoRoot);
|
|
3104
3223
|
const store = await readTodoStore({ repoRoot });
|
|
@@ -3114,31 +3233,31 @@ async function seamProposalCompile({ repoRoot, planKey }) {
|
|
|
3114
3233
|
'SEAM_PROPOSAL_COMPILE_UNAVAILABLE',
|
|
3115
3234
|
independenceArtifact === null ? 'independence_artifact_absent' : 'independence_artifact_superseded',
|
|
3116
3235
|
undefined,
|
|
3117
|
-
{ next_action:
|
|
3236
|
+
{ next_action: independenceCompileCommand(planKey) },
|
|
3118
3237
|
);
|
|
3119
3238
|
}
|
|
3120
3239
|
if (independenceArtifact.outcome !== 'compiled') {
|
|
3121
3240
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'independence_outcome_not_compiled', undefined, {
|
|
3122
3241
|
outcome: independenceArtifact.outcome,
|
|
3123
|
-
next_action:
|
|
3242
|
+
next_action: independenceCompileCommand(planKey),
|
|
3124
3243
|
});
|
|
3125
3244
|
}
|
|
3126
3245
|
if (independenceArtifact.base_sha !== currentBaseSha) {
|
|
3127
3246
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'independence_artifact_stale', undefined, {
|
|
3128
3247
|
independence_base_sha: independenceArtifact.base_sha,
|
|
3129
3248
|
current_base_sha: currentBaseSha,
|
|
3130
|
-
next_action:
|
|
3249
|
+
next_action: independenceCompileCommand(planKey),
|
|
3131
3250
|
});
|
|
3132
3251
|
}
|
|
3133
3252
|
const witnessSet = await readTodoWitnessSet({ repoRoot, planKey });
|
|
3134
3253
|
if (witnessSet === null) {
|
|
3135
3254
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'witness_set_absent', undefined, {
|
|
3136
|
-
next_action:
|
|
3255
|
+
next_action: independenceCompileCommand(planKey),
|
|
3137
3256
|
});
|
|
3138
3257
|
}
|
|
3139
3258
|
if (witnessSet.witness_set_digest !== independenceArtifact.witness_set_digest) {
|
|
3140
3259
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'witness_set_changed', undefined, {
|
|
3141
|
-
next_action:
|
|
3260
|
+
next_action: independenceCompileCommand(planKey),
|
|
3142
3261
|
});
|
|
3143
3262
|
}
|
|
3144
3263
|
|
|
@@ -3235,7 +3354,7 @@ async function witnessScaffold({ repoRoot, planKey, inputRef }) {
|
|
|
3235
3354
|
observed_paths: paths,
|
|
3236
3355
|
task_count: Object.keys(witnessSet.manual_witness).length,
|
|
3237
3356
|
witness_set_digest: witnessSet.witness_set_digest,
|
|
3238
|
-
next_action:
|
|
3357
|
+
next_action: independenceCompileCommand(planKey, ref),
|
|
3239
3358
|
};
|
|
3240
3359
|
}
|
|
3241
3360
|
|
|
@@ -3279,13 +3398,13 @@ async function seamProposalApply({ repoRoot, planKey, pathNames = {}, land = fal
|
|
|
3279
3398
|
const artifact = await readTodoSeamProposalArtifact({ repoRoot, store, planKey });
|
|
3280
3399
|
if (artifact === null) {
|
|
3281
3400
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'seam_proposal_absent', undefined, {
|
|
3282
|
-
plan_key: planKey, next_action:
|
|
3401
|
+
plan_key: planKey, next_action: `lattice todo seam-proposal compile --plan ${planKey}`,
|
|
3283
3402
|
});
|
|
3284
3403
|
}
|
|
3285
3404
|
const witnessSet = await readTodoWitnessSet({ repoRoot, planKey });
|
|
3286
3405
|
if (witnessSet === null) {
|
|
3287
3406
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'witness_set_absent', undefined, {
|
|
3288
|
-
plan_key: planKey, next_action:
|
|
3407
|
+
plan_key: planKey, next_action: independenceCompileCommand(planKey),
|
|
3289
3408
|
});
|
|
3290
3409
|
}
|
|
3291
3410
|
const baseArtifact = await readTodoIndependenceArtifact({ repoRoot, store, planKey });
|
|
@@ -3415,6 +3534,7 @@ async function seamProposal({ repoRoot, requestedPlanKey }) {
|
|
|
3415
3534
|
guidance: selectSeamProposalGuidance({
|
|
3416
3535
|
coverage,
|
|
3417
3536
|
unknownKinds: components.flatMap(({ unknowns }) => unknowns.map(({ kind }) => kind)),
|
|
3537
|
+
planKey,
|
|
3418
3538
|
}),
|
|
3419
3539
|
component_count: artifact === null ? null : components.length,
|
|
3420
3540
|
conflict_resource_count: artifact === null ? null : components
|
|
@@ -3650,7 +3770,7 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3650
3770
|
plan_key: planKey,
|
|
3651
3771
|
coverage: 'superseded',
|
|
3652
3772
|
unreadable_reason: `${error.code}:${error.detail?.reason ?? error.message}`,
|
|
3653
|
-
guidance: selectSeamProposalGuidance({ coverage: 'superseded' }),
|
|
3773
|
+
guidance: selectSeamProposalGuidance({ coverage: 'superseded', planKey }),
|
|
3654
3774
|
component_count: null,
|
|
3655
3775
|
conflict_resource_count: null,
|
|
3656
3776
|
components: [],
|
|
@@ -3663,7 +3783,7 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3663
3783
|
plan_key: planKey,
|
|
3664
3784
|
coverage: 'missing',
|
|
3665
3785
|
unreadable_reason: null,
|
|
3666
|
-
guidance: selectSeamProposalGuidance({ coverage: 'missing' }),
|
|
3786
|
+
guidance: selectSeamProposalGuidance({ coverage: 'missing', planKey }),
|
|
3667
3787
|
component_count: null,
|
|
3668
3788
|
conflict_resource_count: null,
|
|
3669
3789
|
components: [],
|
|
@@ -3699,7 +3819,7 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3699
3819
|
plan_key: planKey,
|
|
3700
3820
|
coverage,
|
|
3701
3821
|
unreadable_reason: unreadableReason,
|
|
3702
|
-
guidance: selectSeamProposalGuidance({ coverage }),
|
|
3822
|
+
guidance: selectSeamProposalGuidance({ coverage, planKey }),
|
|
3703
3823
|
component_count: components.length,
|
|
3704
3824
|
conflict_resource_count: components
|
|
3705
3825
|
.reduce((count, component) => count + component.conflicts.length, 0),
|
|
@@ -4059,9 +4179,9 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4059
4179
|
meaning: 'source_inventory_verification_state',
|
|
4060
4180
|
lifecycle_blocked: false,
|
|
4061
4181
|
dashboard_visibility_blocked: false,
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4182
|
+
// 席の経路は軽い改訂(plan revise)。反映後のplanはreconciledになる。
|
|
4183
|
+
schema_command: reconciled ? null : 'lattice plan revise --schema --json',
|
|
4184
|
+
next_action: reconciled ? null : 'lattice plan revise --input <revision.json> --json',
|
|
4065
4185
|
},
|
|
4066
4186
|
};
|
|
4067
4187
|
});
|
|
@@ -4092,6 +4212,21 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4092
4212
|
return result;
|
|
4093
4213
|
}
|
|
4094
4214
|
|
|
4215
|
+
// `todo verify`の人間向け1行。--jsonと同じresultから導く(verifyは不整合を例外で拒否するので、
|
|
4216
|
+
// ここへ届くのは検証が通った結果だけ。注意が要るのはsnapshot古さとcommit前の証拠)。
|
|
4217
|
+
function verifyVerdictLine(result) {
|
|
4218
|
+
const members = result.verified_members.map((member) => `${member.plan_key} ${member.reconciliation_state}${
|
|
4219
|
+
member.reconciliation_state === 'reconciled' ? '' : ', lifecycle not blocked'}`);
|
|
4220
|
+
const notes = [];
|
|
4221
|
+
if (result.snapshot_stale) notes.push('snapshot stale');
|
|
4222
|
+
if (result.uncommitted_evidence.length > 0) {
|
|
4223
|
+
notes.push(`${result.uncommitted_evidence.length} uncommitted evidence (commit it, then rerun)`);
|
|
4224
|
+
}
|
|
4225
|
+
const count = result.verified_members.length;
|
|
4226
|
+
return `todo verify: ${notes.length === 0 ? 'ok' : 'attention'}, ${count} plan${count === 1 ? '' : 's'} verified`
|
|
4227
|
+
+ `${notes.map((note) => `, ${note}`).join('')} (${members.join('; ')})`;
|
|
4228
|
+
}
|
|
4229
|
+
|
|
4095
4230
|
async function rebuildSnapshot({ repoRoot, planKey }) {
|
|
4096
4231
|
// Read first so every typed validation failure happens before the rebuild writer is entered.
|
|
4097
4232
|
const store = await readTodoStore({ repoRoot });
|
|
@@ -4189,6 +4324,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4189
4324
|
|
|
4190
4325
|
const automatedStructureRealize = parseAutomatedStructureRealizeArgs(argv);
|
|
4191
4326
|
let action = null;
|
|
4327
|
+
let plainVerify = false; // a19: `todo verify`は--jsonが無ければ1行の判定だけを返す
|
|
4192
4328
|
if (argv.length === 2 && argv[0] === 'repair-eol' && argv[1] === '--json') {
|
|
4193
4329
|
// 壊れたstoreを読めない時の入口なので、dashboard所有権pre-hookを通さない。
|
|
4194
4330
|
action = (repoRoot) => repairStoreEol({ repoRoot });
|
|
@@ -4255,25 +4391,19 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4255
4391
|
action = (repoRoot) => independenceMode({
|
|
4256
4392
|
repoRoot, env, planKey: argv[3], mode: argv[5], reason: argv[7],
|
|
4257
4393
|
});
|
|
4258
|
-
} else if (argv
|
|
4259
|
-
&& argv
|
|
4260
|
-
|
|
4261
|
-
&& argv[6] === '--to-plan' && isTodoIdentifier(argv[7])
|
|
4262
|
-
&& argv[8] === '--to-task' && isTodoIdentifier(argv[9])
|
|
4263
|
-
&& argv[10] === '--reason' && argv[11].length > 0) {
|
|
4394
|
+
} else if (argv[0] === 'dependency' && argv[1] === 'connect'
|
|
4395
|
+
&& dependencyFlags(argv) !== null) {
|
|
4396
|
+
const flags = dependencyFlags(argv);
|
|
4264
4397
|
action = (repoRoot) => dependencyConnect({
|
|
4265
|
-
repoRoot, env, fromPlanKey:
|
|
4266
|
-
toPlanKey:
|
|
4398
|
+
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
4399
|
+
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
4267
4400
|
});
|
|
4268
|
-
} else if (argv
|
|
4269
|
-
&& argv
|
|
4270
|
-
|
|
4271
|
-
&& argv[6] === '--to-plan' && isTodoIdentifier(argv[7])
|
|
4272
|
-
&& argv[8] === '--to-task' && isTodoIdentifier(argv[9])
|
|
4273
|
-
&& argv[10] === '--reason' && argv[11].length > 0) {
|
|
4401
|
+
} else if (argv[0] === 'dependency' && argv[1] === 'disconnect'
|
|
4402
|
+
&& dependencyFlags(argv) !== null) {
|
|
4403
|
+
const flags = dependencyFlags(argv);
|
|
4274
4404
|
action = (repoRoot) => dependencyDisconnect({
|
|
4275
|
-
repoRoot, env, fromPlanKey:
|
|
4276
|
-
toPlanKey:
|
|
4405
|
+
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
4406
|
+
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
4277
4407
|
});
|
|
4278
4408
|
} else if (argv[0] === 'independence' && argv[1] === 'compile') {
|
|
4279
4409
|
const flags = matchFlagCommand(argv, ['independence', 'compile'], {
|
|
@@ -4367,10 +4497,12 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4367
4497
|
action = (repoRoot) => seamProposal({ repoRoot, requestedPlanKey: argv[2] });
|
|
4368
4498
|
} else if ((argv.length === 1 && argv[0] === 'verify')
|
|
4369
4499
|
|| (argv.length === 2 && argv[0] === 'verify' && argv[1] === '--json')) {
|
|
4500
|
+
plainVerify = argv.length === 1;
|
|
4370
4501
|
action = (repoRoot) => verify({ repoRoot, requestedPlanKey: null });
|
|
4371
4502
|
} else if ((argv.length === 3 || argv.length === 4) && argv[0] === 'verify'
|
|
4372
4503
|
&& argv[1] === '--plan' && isTodoIdentifier(argv[2])
|
|
4373
4504
|
&& (argv.length === 3 || argv[3] === '--json')) {
|
|
4505
|
+
plainVerify = argv.length === 3;
|
|
4374
4506
|
action = (repoRoot) => verify({ repoRoot, requestedPlanKey: argv[2] });
|
|
4375
4507
|
} else if (argv.length === 4 && argv[0] === 'snapshot' && argv[1] === '--rebuild'
|
|
4376
4508
|
&& argv[2] === '--plan' && isTodoIdentifier(argv[3])) {
|
|
@@ -4479,11 +4611,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4479
4611
|
const exceptPlanKeys = parseBaselineExceptFlags(argv.slice(4));
|
|
4480
4612
|
action = (repoRoot) => phaseBaseline({ repoRoot, env, reason: argv[3], exceptPlanKeys });
|
|
4481
4613
|
} else if (argv[0] === 'start') {
|
|
4482
|
-
const flags = matchFlagCommand(argv, ['start'],
|
|
4483
|
-
known: ['plan', 'task', 'parallel-frontier', 'override-reason', 'serial-confirmed', 'rebind', 'reason'],
|
|
4484
|
-
required: ['plan', 'task'],
|
|
4485
|
-
booleans: ['parallel-frontier', 'serial-confirmed', 'rebind'],
|
|
4486
|
-
});
|
|
4614
|
+
const flags = matchFlagCommand(argv, ['start'], TODO_FLAG_SPECS.start);
|
|
4487
4615
|
if (flags !== null && flags.rebind === true) {
|
|
4488
4616
|
if (isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)
|
|
4489
4617
|
&& typeof flags.reason === 'string' && flags.reason.length > 0) {
|
|
@@ -4508,7 +4636,9 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4508
4636
|
&& (flags.evidence === undefined || hasEvidence)
|
|
4509
4637
|
&& (flags['test-result'] === undefined || isAuthoringPathToken(flags['test-result']))) {
|
|
4510
4638
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4511
|
-
kind: 'done',
|
|
4639
|
+
kind: 'done', notRecorded: ['message', 'evidence', 'test-result']
|
|
4640
|
+
.filter((name) => flags[name] !== undefined).map((name) => `--${name}`),
|
|
4641
|
+
action: async () => {
|
|
4512
4642
|
let evidenceMessage = hasMessage ? flags.message : null;
|
|
4513
4643
|
if (hasEvidence && hasMessage) {
|
|
4514
4644
|
// The message is the record; it names the resolved file so nothing given is lost.
|
|
@@ -4532,18 +4662,14 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4532
4662
|
}
|
|
4533
4663
|
}
|
|
4534
4664
|
if (action === null && argv[0] === 'retract') {
|
|
4535
|
-
const flags = matchFlagCommand(argv, ['retract'],
|
|
4536
|
-
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4537
|
-
});
|
|
4665
|
+
const flags = matchFlagCommand(argv, ['retract'], TODO_FLAG_SPECS.retract);
|
|
4538
4666
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4539
4667
|
action = (repoRoot) => retractStart({
|
|
4540
4668
|
repoRoot, env, planKey: flags.plan, taskId: flags.task, reason: flags.reason,
|
|
4541
4669
|
});
|
|
4542
4670
|
}
|
|
4543
4671
|
} else if (argv[0] === 'block') {
|
|
4544
|
-
const flags = matchFlagCommand(argv, ['block'],
|
|
4545
|
-
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4546
|
-
});
|
|
4672
|
+
const flags = matchFlagCommand(argv, ['block'], TODO_FLAG_SPECS.block);
|
|
4547
4673
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4548
4674
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4549
4675
|
kind: 'block', action: () => mutate({
|
|
@@ -4553,18 +4679,14 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4553
4679
|
}
|
|
4554
4680
|
} else if (argv[0] === 'retire') {
|
|
4555
4681
|
// 恒久除去(2026-08-29オーナー裁定)。planの形は変えず、状態遷移として工程を閉じる。
|
|
4556
|
-
const flags = matchFlagCommand(argv, ['retire'],
|
|
4557
|
-
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4558
|
-
});
|
|
4682
|
+
const flags = matchFlagCommand(argv, ['retire'], TODO_FLAG_SPECS.retire);
|
|
4559
4683
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4560
4684
|
action = (repoRoot) => retireTask({
|
|
4561
4685
|
repoRoot, env, planKey: flags.plan, taskId: flags.task, reason: flags.reason,
|
|
4562
4686
|
});
|
|
4563
4687
|
}
|
|
4564
4688
|
} else if (argv[0] === 'unblock') {
|
|
4565
|
-
const flags = matchFlagCommand(argv, ['unblock'],
|
|
4566
|
-
known: ['plan', 'task'], required: ['plan', 'task'],
|
|
4567
|
-
});
|
|
4689
|
+
const flags = matchFlagCommand(argv, ['unblock'], TODO_FLAG_SPECS.unblock);
|
|
4568
4690
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4569
4691
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4570
4692
|
kind: 'unblock', action: () => mutate({
|
|
@@ -4584,10 +4706,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4584
4706
|
});
|
|
4585
4707
|
}
|
|
4586
4708
|
} else if (argv[0] === 'reopen') {
|
|
4587
|
-
const flags = matchFlagCommand(argv, ['reopen'],
|
|
4588
|
-
known: ['plan', 'task', 'reason', 'override-reason'],
|
|
4589
|
-
required: ['plan', 'task', 'reason'],
|
|
4590
|
-
});
|
|
4709
|
+
const flags = matchFlagCommand(argv, ['reopen'], TODO_FLAG_SPECS.reopen);
|
|
4591
4710
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)
|
|
4592
4711
|
&& (flags['override-reason'] === undefined
|
|
4593
4712
|
|| (typeof flags['override-reason'] === 'string' && flags['override-reason'].length > 0))) {
|
|
@@ -4642,7 +4761,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4642
4761
|
const result = atomicCommit
|
|
4643
4762
|
? await commitTodoStoreMutation({ repoRoot, argv, action, env })
|
|
4644
4763
|
: await action(repoRoot);
|
|
4645
|
-
if (result !== null) stdout.write(`${JSON.stringify(result)}\n`);
|
|
4764
|
+
if (result !== null) stdout.write(`${plainVerify ? verifyVerdictLine(result) : JSON.stringify(result)}\n`);
|
|
4646
4765
|
return 0;
|
|
4647
4766
|
} catch (error) {
|
|
4648
4767
|
if (error instanceof TodoStoreError || (typeof error?.code === 'string'
|
|
@@ -510,10 +510,13 @@ function activeConflictEntry(value) {
|
|
|
510
510
|
* 案内。単一正本のcatalogが返した形をそのまま載せる(ADR 0130 Decision 1・2)。
|
|
511
511
|
* 面ごとに文言を組み立て直さないため、ここではshapeだけを検査する。
|
|
512
512
|
*/
|
|
513
|
+
// next_actionは実在コマンド(`lattice ...`)か'none'(a19)。
|
|
514
|
+
const commandOrNone = (value) => value === 'none' || (boundedText(value) && value.startsWith('lattice '));
|
|
515
|
+
|
|
513
516
|
function guidanceEntry(value) {
|
|
514
517
|
return exactRecord(value, ['code', 'message', 'next_action'])
|
|
515
518
|
&& TODO_INDEPENDENCE_GUIDANCE_CODES.includes(value.code)
|
|
516
|
-
&& boundedText(value.message) &&
|
|
519
|
+
&& boundedText(value.message) && commandOrNone(value.next_action);
|
|
517
520
|
}
|
|
518
521
|
|
|
519
522
|
/**
|