@quolu/lattice 0.84.2 → 0.85.1
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 +37 -13
- 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 +15 -6
- package/src/cli-refusal-guidance.mjs +57 -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 +47 -23
- package/src/runtime-pull-intake.mjs +2 -2
- package/src/seam-proposal-contracts.mjs +2 -1
- package/src/setup-cli.mjs +4 -1
- package/src/todo-authoring-input.mjs +26 -8
- package/src/todo-cli.mjs +332 -153
- 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,107 @@ 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 PHASE_REASON_FLAG_SPEC = Object.freeze({ known: ['plan', 'phase', 'reason'], required: ['plan', 'phase', 'reason'] });
|
|
297
|
+
const NOTE_FLAG_SPEC = Object.freeze({ known: ['plan', 'task', 'message', 'input', 'supersedes'], required: ['plan'] });
|
|
298
|
+
const DEPENDENCY_FLAG_SPEC = Object.freeze({
|
|
299
|
+
known: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
300
|
+
required: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
301
|
+
});
|
|
302
|
+
// a18: one spec per write command is both its parser and the explanation of its refusal.
|
|
303
|
+
const TODO_FLAG_SPECS = Object.freeze({
|
|
304
|
+
start: Object.freeze({
|
|
305
|
+
known: ['plan', 'task', 'parallel-frontier', 'override-reason', 'serial-confirmed', 'rebind', 'reason'],
|
|
306
|
+
required: ['plan', 'task'],
|
|
307
|
+
booleans: ['parallel-frontier', 'serial-confirmed', 'rebind'],
|
|
308
|
+
}),
|
|
309
|
+
done: DONE_FLAG_SPEC,
|
|
310
|
+
block: REASON_FLAG_SPEC,
|
|
311
|
+
retire: REASON_FLAG_SPEC,
|
|
312
|
+
retract: REASON_FLAG_SPEC,
|
|
313
|
+
unblock: Object.freeze({ known: ['plan', 'task'], required: ['plan', 'task'] }),
|
|
314
|
+
reopen: Object.freeze({ known: ['plan', 'task', 'reason', 'override-reason'], required: ['plan', 'task', 'reason'] }),
|
|
315
|
+
'dependency connect': DEPENDENCY_FLAG_SPEC,
|
|
316
|
+
'dependency disconnect': DEPENDENCY_FLAG_SPEC,
|
|
317
|
+
// a23: the remaining writes whose refusal pointed only at --help.
|
|
318
|
+
'phase review': PHASE_REASON_FLAG_SPEC,
|
|
319
|
+
'phase close-unaudited': PHASE_REASON_FLAG_SPEC,
|
|
320
|
+
split: Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
321
|
+
note: NOTE_FLAG_SPEC,
|
|
322
|
+
});
|
|
323
|
+
const IDENTIFIER_FLAGS = ['plan', 'task', 'phase', 'from-plan', 'from-task', 'to-plan', 'to-task'];
|
|
324
|
+
const FLAG_PLACEHOLDER = { reason: '<text>', 'override-reason': '<text>', message: '<text>',
|
|
325
|
+
evidence: '<file>', 'test-result': '<file>', input: '<file>' };
|
|
326
|
+
const shellWord = (value) => (/^[\w./:@-]+$/u.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`);
|
|
327
|
+
|
|
328
|
+
/** The command again, with the flags given and a placeholder for each missing required flag. */
|
|
329
|
+
function repairedCommand(head, spec, flags) {
|
|
330
|
+
const words = ['lattice', 'todo', ...head];
|
|
331
|
+
for (const name of spec.known) {
|
|
332
|
+
if (typeof flags[name] === 'string' && flags[name].length > 0) words.push(`--${name}`, shellWord(flags[name]));
|
|
333
|
+
else if (flags[name] === true && spec.booleans?.includes(name)) words.push(`--${name}`);
|
|
334
|
+
else if (spec.required.includes(name)) words.push(`--${name}`, FLAG_PLACEHOLDER[name] ?? `<${name}>`);
|
|
335
|
+
}
|
|
336
|
+
return words.join(' ');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** `dependency connect|disconnect` flags by name (order-free), or null. */
|
|
340
|
+
function dependencyFlags(argv) {
|
|
341
|
+
const flags = matchFlagCommand(argv, argv.slice(0, 2), DEPENDENCY_FLAG_SPEC);
|
|
342
|
+
return flags !== null && IDENTIFIER_FLAGS.slice(3).every((name) => isTodoIdentifier(flags[name])) ? flags : null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** `phase review|close-unaudited` flags by name (order-free), or null. */
|
|
346
|
+
function phaseReasonFlags(argv) {
|
|
347
|
+
const flags = matchFlagCommand(argv, argv.slice(0, 2), PHASE_REASON_FLAG_SPEC);
|
|
348
|
+
return flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.phase) ? flags : null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** A todo write's argument refusal names the flag, the rule and the command to run instead. */
|
|
295
352
|
function explainArgumentRefusal(argv) {
|
|
296
|
-
if (argv[0]
|
|
297
|
-
const
|
|
353
|
+
if (argv[0] === 'note' && argv[1] === 'list') return {};
|
|
354
|
+
const head = ['dependency', 'phase'].includes(argv[0]) ? argv.slice(0, 2) : argv.slice(0, 1);
|
|
355
|
+
const spec = TODO_FLAG_SPECS[head.join(' ')];
|
|
356
|
+
if (spec === undefined) return {};
|
|
357
|
+
const { flags } = parseFlagMap(argv.slice(head.length));
|
|
358
|
+
const flagFailure = explainFlagCommand(argv, head, spec);
|
|
359
|
+
if (flagFailure?.rule === 'flag_missing') {
|
|
360
|
+
return { ...flagFailure, next_action: `Add ${flagFailure.pointer} ${FLAG_PLACEHOLDER[flagFailure.pointer.slice(2)] ?? '<value>'}: \`${repairedCommand(head, spec, flags)}\`.` };
|
|
361
|
+
}
|
|
298
362
|
if (flagFailure !== null) return flagFailure;
|
|
299
|
-
const
|
|
300
|
-
|
|
363
|
+
for (const name of IDENTIFIER_FLAGS.filter((key) => spec.known.includes(key))) {
|
|
364
|
+
if (flags[name] === undefined && !spec.required.includes(name)) continue;
|
|
301
365
|
if (!isTodoIdentifier(flags[name])) return { pointer: `--${name}`, rule: 'identifier_invalid', actual: flags[name] };
|
|
302
366
|
}
|
|
367
|
+
if (argv[0] === 'note') {
|
|
368
|
+
const given = ['message', 'input'].filter((name) => typeof flags[name] === 'string' && flags[name].length > 0);
|
|
369
|
+
if (given.length === 0) {
|
|
370
|
+
return { pointer: '--message', rule: 'flag_missing',
|
|
371
|
+
next_action: `Add --message <text> (or --input <file>): \`${repairedCommand(head, { ...spec, required: [...spec.required, 'message'] }, flags)}\`.` };
|
|
372
|
+
}
|
|
373
|
+
if (flags.supersedes !== undefined && !isTodoDigest(flags.supersedes)) {
|
|
374
|
+
return { pointer: '--supersedes', rule: 'digest_invalid', actual: flags.supersedes,
|
|
375
|
+
next_action: `Pass the note_digest of the note to replace (see \`lattice todo note list --plan ${flags.plan} --json\`).` };
|
|
376
|
+
}
|
|
377
|
+
if (given.length === 2) {
|
|
378
|
+
return { pointer: '--input', rule: 'flags_exclusive',
|
|
379
|
+
next_action: `Pass either --message or --input, not both: \`${repairedCommand(head, spec, { ...flags, input: undefined })}\`.` };
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (spec.known.includes('input') && flags.input !== undefined && !isAuthoringPathToken(flags.input)) {
|
|
383
|
+
return { pointer: '--input', rule: 'path_token_invalid' };
|
|
384
|
+
}
|
|
385
|
+
for (const name of ['override-reason', 'reason']) {
|
|
386
|
+
if (spec.known.includes(name) && flags[name] !== undefined
|
|
387
|
+
&& !(typeof flags[name] === 'string' && flags[name].length > 0)) {
|
|
388
|
+
return { pointer: `--${name}`, rule: 'flag_missing', next_action: `Give --${name} a non-empty <text>: \`${repairedCommand(head, spec, flags)}\`.` };
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (argv[0] === 'start' && flags.rebind === true && !(typeof flags.reason === 'string' && flags.reason.length > 0)) {
|
|
392
|
+
return { pointer: '--reason', rule: 'flag_missing',
|
|
393
|
+
next_action: `--rebind needs --reason <text>: \`${repairedCommand(head, { ...spec, required: [...spec.required, 'reason'] }, flags)}\`.` };
|
|
394
|
+
}
|
|
395
|
+
if (argv[0] !== 'done') return {};
|
|
303
396
|
const hasMessage = typeof flags.message === 'string' && flags.message.length > 0;
|
|
304
397
|
if (flags.message !== undefined && !hasMessage) return { pointer: '--message', rule: 'flag_missing' };
|
|
305
398
|
if (flags.evidence !== undefined && !isAuthoringPathToken(flags.evidence)) {
|
|
@@ -374,7 +467,8 @@ function selectNoteTask(member, requestedTaskId) {
|
|
|
374
467
|
}
|
|
375
468
|
|
|
376
469
|
async function readNoteTextInput(repoRoot, inputRef) {
|
|
377
|
-
|
|
470
|
+
// a23: the text is stored in the journal, so (like plan input) a file outside the repo is read too.
|
|
471
|
+
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag: '--message', allowOutsideRepo: true });
|
|
378
472
|
const bytes = await readFile(located.absolute);
|
|
379
473
|
if (bytes.length > MAX_NOTE_INPUT_BYTES) {
|
|
380
474
|
throw new TodoStoreError('INPUT_TOO_LARGE', 'note_input_too_large');
|
|
@@ -507,23 +601,30 @@ function looksLikeEvidenceDescriptor(value) {
|
|
|
507
601
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
508
602
|
}
|
|
509
603
|
|
|
510
|
-
function writeEvidenceBlob(repoRoot, bytes, blobPath) {
|
|
604
|
+
function writeEvidenceBlob(repoRoot, bytes, blobPath, write = true) {
|
|
511
605
|
// worktree pathから作る証拠は`git add`と同じclean filterを通す。生のCRLF bytesを
|
|
512
606
|
// そのままhashすると、commit先はLFへ正規化される一方、descriptorはdangling blobを
|
|
513
607
|
// 指すため、commit後もhard検証を通せない。
|
|
514
|
-
const oid = gitSync(['hash-object', '-w', `--path=${blobPath}`, '--stdin'], {
|
|
608
|
+
const oid = gitSync(['hash-object', ...(write ? ['-w'] : []), `--path=${blobPath}`, '--stdin'], {
|
|
515
609
|
cwd: repoRoot, input: bytes, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'],
|
|
516
610
|
}).trim();
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
611
|
+
let storedBytes;
|
|
612
|
+
try {
|
|
613
|
+
storedBytes = gitSync(['cat-file', 'blob', oid], { cwd: repoRoot, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
614
|
+
} catch (error) {
|
|
615
|
+
// a23: a comparison-only hash writes nothing; content never stored has no digest to compare.
|
|
616
|
+
if (!write) return { git_blob_oid: oid, content_digest: null };
|
|
617
|
+
throw error;
|
|
618
|
+
}
|
|
520
619
|
return {
|
|
521
620
|
git_blob_oid: oid,
|
|
522
621
|
content_digest: createHash('sha256').update(storedBytes).digest('hex'),
|
|
523
622
|
};
|
|
524
623
|
}
|
|
525
624
|
|
|
526
|
-
async function resolveDoneEvidence({
|
|
625
|
+
async function resolveDoneEvidence({
|
|
626
|
+
repoRoot, evidenceRef, evidenceMessage, planKey, taskId, write = true, inlineFlag = null,
|
|
627
|
+
}) {
|
|
527
628
|
if (typeof evidenceMessage === 'string') {
|
|
528
629
|
const bytes = Buffer.from(evidenceMessage, 'utf8');
|
|
529
630
|
const sourceDigest = createHash('sha256').update(bytes).digest('hex');
|
|
@@ -532,16 +633,16 @@ async function resolveDoneEvidence({ repoRoot, evidenceRef, evidenceMessage, pla
|
|
|
532
633
|
evidence_id: evidenceIdFor(planKey, taskId),
|
|
533
634
|
repo_id: 'self',
|
|
534
635
|
path: evidencePath,
|
|
535
|
-
...writeEvidenceBlob(repoRoot, bytes, evidencePath),
|
|
636
|
+
...writeEvidenceBlob(repoRoot, bytes, evidencePath, write),
|
|
536
637
|
media_type: 'text/markdown',
|
|
537
638
|
anchor_digest: null,
|
|
538
639
|
};
|
|
539
|
-
if (!validateEvidenceDescriptor(descriptor) || !isTodoRef(descriptor.path)) {
|
|
640
|
+
if (write && (!validateEvidenceDescriptor(descriptor) || !isTodoRef(descriptor.path))) {
|
|
540
641
|
throw new TodoStoreError('INVALID_EVIDENCE', 'authored_evidence_descriptor_invalid');
|
|
541
642
|
}
|
|
542
643
|
return descriptor;
|
|
543
644
|
}
|
|
544
|
-
const located = await resolveAuthoringInputPath(repoRoot, evidenceRef, { inlineFlag
|
|
645
|
+
const located = await resolveAuthoringInputPath(repoRoot, evidenceRef, { inlineFlag });
|
|
545
646
|
const bytes = await readFile(located.absolute);
|
|
546
647
|
let text;
|
|
547
648
|
try { text = new TextDecoder('utf-8', { fatal: true }).decode(bytes); }
|
|
@@ -564,11 +665,11 @@ async function resolveDoneEvidence({ repoRoot, evidenceRef, evidenceMessage, pla
|
|
|
564
665
|
evidence_id: evidenceIdFor(planKey, taskId),
|
|
565
666
|
repo_id: 'self',
|
|
566
667
|
path: located.inputRef,
|
|
567
|
-
...writeEvidenceBlob(repoRoot, bytes, located.inputRef),
|
|
668
|
+
...writeEvidenceBlob(repoRoot, bytes, located.inputRef, write),
|
|
568
669
|
media_type: mediaTypeFor(located.inputRef),
|
|
569
670
|
anchor_digest: null,
|
|
570
671
|
};
|
|
571
|
-
if (!validateEvidenceDescriptor(descriptor)) {
|
|
672
|
+
if (write && !validateEvidenceDescriptor(descriptor)) {
|
|
572
673
|
throw new TodoStoreError('INVALID_EVIDENCE', 'authored_evidence_descriptor_invalid');
|
|
573
674
|
}
|
|
574
675
|
return descriptor;
|
|
@@ -626,23 +727,13 @@ async function readStructureSetDraft(repoRoot, inputRef) {
|
|
|
626
727
|
}
|
|
627
728
|
|
|
628
729
|
/**
|
|
629
|
-
* gate_ready
|
|
630
|
-
*
|
|
631
|
-
* 0.36.0で入れた終端監査gate(ADR 0147)は、これから終わる工程だけでなく過去に完了した
|
|
632
|
-
* 工程まで監査待ちにしてしまっていた——原因を言わないgateは、なぜ止まっているかを
|
|
633
|
-
* 説明しないのと同じなので、ここでその経緯を明示する。次の一歩は2択で書く:
|
|
634
|
-
* 今から監査する(review→accept)か、監査せず歴史として閉じる(close-unaudited、
|
|
635
|
-
* 複数plan一括ならbaseline)か。
|
|
730
|
+
* gate_readyの次の一歩を1行で言う(ADR 0148裁定8・a22)。全taskが終わった席には、軽い出口
|
|
731
|
+
* (監査せず閉じるclose-unaudited)を先に、監査する道(review→accept)を後に示す。経緯の説明は載せない。
|
|
636
732
|
*/
|
|
637
733
|
function auditGateGuidance(planKey, phaseId) {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
+
|
|
641
|
-
+ `todo phase review --plan ${planKey} --phase ${phaseId} --reason <text> → `
|
|
642
|
-
+ `todo phase accept --plan ${planKey} --phase ${phaseId} --input <file>。`
|
|
643
|
-
+ '監査せず歴史として閉じるなら: '
|
|
644
|
-
+ `todo phase close-unaudited --plan ${planKey} --phase ${phaseId} --reason <text>`
|
|
645
|
-
+ '(複数planをまとめて畳むなら todo phase baseline --reason <text> [--except <plan_key>]...)。';
|
|
734
|
+
const target = `--plan ${planKey} --phase ${phaseId}`;
|
|
735
|
+
return `全ToDoがdone。監査せず閉じるなら: lattice todo phase close-unaudited ${target} --reason <text>`
|
|
736
|
+
+ `(監査するなら lattice todo phase review ${target} --reason <text> → accept ${target} --input <file>)`;
|
|
646
737
|
}
|
|
647
738
|
|
|
648
739
|
/**
|
|
@@ -699,13 +790,15 @@ function reopenAdvisory(plan, phases, taskId) {
|
|
|
699
790
|
async function mutate({
|
|
700
791
|
repoRoot, env, planKey, taskId, kind, payload, evidenceRef, evidenceMessage = null,
|
|
701
792
|
advisory = null, noteContext = null, structureContext = null, featureContext = null,
|
|
702
|
-
testResultRef = null,
|
|
793
|
+
testResultRef = null, actor: carriedActor = null,
|
|
703
794
|
}) {
|
|
704
|
-
const actor = resolveTodoActor(env);
|
|
795
|
+
const actor = carriedActor ?? resolveTodoActor(env);
|
|
705
796
|
const evidence = evidenceRef === null && evidenceMessage === null
|
|
706
797
|
? null
|
|
707
798
|
: await resolveDoneEvidence({
|
|
708
799
|
repoRoot, evidenceRef, evidenceMessage, planKey, taskId,
|
|
800
|
+
// Only an authored done takes --message as the inline alternative to --evidence.
|
|
801
|
+
inlineFlag: kind === 'done' && payload === 'authored' ? '--message' : null,
|
|
709
802
|
});
|
|
710
803
|
const testResult = testResultRef === null ? null : await readTestResultInput(repoRoot, testResultRef);
|
|
711
804
|
const materializedEvidence = typeof evidenceMessage === 'string'
|
|
@@ -791,8 +884,21 @@ const UNCHANGED_WHEN = {
|
|
|
791
884
|
retire: ({ status }) => status === 'retired',
|
|
792
885
|
};
|
|
793
886
|
|
|
794
|
-
|
|
795
|
-
|
|
887
|
+
// a23: what a repeated transition drops (given content differing from the record), and how to keep it.
|
|
888
|
+
const NOT_RECORDED_NEXT = {
|
|
889
|
+
done: (on, flags) => `was already done; ${flags} not recorded. Keep the text with \`lattice todo note ${on} --message <text>\`,`
|
|
890
|
+
+ ` or replace the record: \`lattice todo reopen ${on} --reason <text>\`, then start and done again.`,
|
|
891
|
+
block: (on, flags) => `was already blocked; ${flags} not recorded. Keep the text with \`lattice todo note ${on} --message <text>\`,`
|
|
892
|
+
+ ` or record the new reason: \`lattice todo unblock ${on}\`, then \`lattice todo block ${on} --reason <text>\`.`,
|
|
893
|
+
retire: (on, flags) => `was already retired (permanent); ${flags} not recorded.`
|
|
894
|
+
+ ` Keep the text with \`lattice todo note ${on} --message <text>\`.`,
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Unchanged result, or null when the transition must go to the append path.
|
|
899
|
+
* `dropped(recordedEvent)` returns the given flags whose content the record does not hold.
|
|
900
|
+
*/
|
|
901
|
+
async function unchangedTransition(store, { env, planKey, taskId, kind, dropped = async () => [] }) {
|
|
796
902
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
797
903
|
const matches = member?.tasks.filter(({ task_id: current }) => current.toLowerCase() === taskId.toLowerCase()) ?? [];
|
|
798
904
|
// Unknown or ambiguous plan/task: the append path keeps Store's refusal.
|
|
@@ -803,12 +909,19 @@ function unchangedTransition(store, { env, planKey, taskId, kind }) {
|
|
|
803
909
|
// Another seat's in-progress task is not this seat's repeated start; keep the task_state refusal.
|
|
804
910
|
if (kind === 'start' && recorded?.actor?.agent !== resolveTodoActor(env).agent) return null;
|
|
805
911
|
const shown = recorded ?? events.findLast((event) => event.task_id === state.task_id) ?? events.at(-1);
|
|
912
|
+
const notRecorded = await dropped(recorded);
|
|
806
913
|
const result = {
|
|
807
914
|
schema: 'lattice.todo_mutation_result.v2',
|
|
808
915
|
project_id: member.plan.project_id, plan_key: planKey, plan_version: member.plan.plan_version,
|
|
809
916
|
task_id: state.task_id, kind, sequence: shown.sequence, event_digest: shown.event_digest,
|
|
810
917
|
journal_head_digest: events.at(-1).event_digest, snapshot_digest: member.snapshot.snapshot_digest,
|
|
811
|
-
status: state.status, advisory: null, unchanged: true,
|
|
918
|
+
status: state.status, advisory: null, unchanged: true,
|
|
919
|
+
// a18: a repeated transition appends nothing, so say which given content was not recorded.
|
|
920
|
+
...(notRecorded.length === 0 ? {} : {
|
|
921
|
+
not_recorded: notRecorded,
|
|
922
|
+
next_action: `${planKey}/${state.task_id} ${NOT_RECORDED_NEXT[kind](`--plan ${planKey} --task ${state.task_id}`, notRecorded.join(', '))}`,
|
|
923
|
+
}),
|
|
924
|
+
result_digest: '',
|
|
812
925
|
};
|
|
813
926
|
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
814
927
|
return result;
|
|
@@ -817,7 +930,66 @@ function unchangedTransition(store, { env, planKey, taskId, kind }) {
|
|
|
817
930
|
/** block/unblock/done: an unchanged no-op first, else the append path. */
|
|
818
931
|
async function mutateUnlessUnchanged(options) {
|
|
819
932
|
const store = await readTodoStore({ repoRoot: options.repoRoot });
|
|
820
|
-
return unchangedTransition(store, options) ?? options.action();
|
|
933
|
+
return (await unchangedTransition(store, options)) ?? options.action();
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/** a23: block/retire drop a --reason that differs from the recorded one. */
|
|
937
|
+
const reasonDropped = (reason) => async (recorded) => (recorded?.payload?.reason === reason ? [] : ['--reason']);
|
|
938
|
+
|
|
939
|
+
/** The evidence a `todo done` records: the message (naming the file when both are given), the file, or the default text. */
|
|
940
|
+
async function doneEvidenceInput({ repoRoot, flags, write = true }) {
|
|
941
|
+
const hasEvidence = isAuthoringPathToken(flags.evidence);
|
|
942
|
+
const hasMessage = typeof flags.message === 'string' && flags.message.length > 0;
|
|
943
|
+
if (hasEvidence && hasMessage) {
|
|
944
|
+
// The message is the record; it names the resolved file so nothing given is lost.
|
|
945
|
+
const file = await resolveDoneEvidence({
|
|
946
|
+
repoRoot, evidenceRef: flags.evidence, evidenceMessage: null, planKey: flags.plan, taskId: flags.task,
|
|
947
|
+
write, inlineFlag: '--message',
|
|
948
|
+
});
|
|
949
|
+
return { evidenceRef: null, evidenceMessage: `${flags.message}\n\nevidence: ${file.repo_id}:${file.path}`
|
|
950
|
+
+ ` (git blob ${file.git_blob_oid}, sha256 ${file.content_digest})\n` };
|
|
951
|
+
}
|
|
952
|
+
if (hasEvidence) return { evidenceRef: flags.evidence, evidenceMessage: null };
|
|
953
|
+
return { evidenceRef: null, evidenceMessage: hasMessage ? flags.message : DONE_WITHOUT_EVIDENCE_MESSAGE };
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* a23: the content flags of a repeated done that the recorded done does not hold. Compared by git blob,
|
|
958
|
+
* hashed without writing; a file that cannot be read counts as differing.
|
|
959
|
+
*/
|
|
960
|
+
async function doneDropped({ repoRoot, flags, recorded }) {
|
|
961
|
+
const given = (names) => names.filter((name) => flags[name] !== undefined).map((name) => `--${name}`);
|
|
962
|
+
const sameEvidence = async () => {
|
|
963
|
+
const evidence = await resolveDoneEvidence({ repoRoot, ...await doneEvidenceInput({ repoRoot, flags, write: false }),
|
|
964
|
+
planKey: flags.plan, taskId: flags.task, write: false });
|
|
965
|
+
return evidence.git_blob_oid === recorded?.payload?.evidence?.git_blob_oid;
|
|
966
|
+
};
|
|
967
|
+
const sameTestResult = async () => (await readTestResultInput(repoRoot, flags['test-result'])) === recorded?.payload?.test_result;
|
|
968
|
+
const differs = async (same) => { try { return !(await same()); } catch { return true; } };
|
|
969
|
+
return [
|
|
970
|
+
...(given(['message', 'evidence']).length > 0 && await differs(sameEvidence) ? given(['message', 'evidence']) : []),
|
|
971
|
+
...(flags['test-result'] !== undefined && await differs(sameTestResult) ? ['--test-result'] : []),
|
|
972
|
+
];
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/** a18: the live tasks with an edge (plan, join or ledger) from the task being retired, sorted. */
|
|
976
|
+
function retireDependents(store, member, taskId) {
|
|
977
|
+
const planKey = member.plan.plan_key;
|
|
978
|
+
const fromIt = (ref) => ref.plan_key === planKey && ref.task_id === taskId;
|
|
979
|
+
const targets = [
|
|
980
|
+
...member.plan.hard_dependencies.filter((edge) => fromIt(edge.from)).map((edge) => edge.to),
|
|
981
|
+
...member.plan.joins.filter((join) => join.after.some(fromIt)).map((join) => join.before),
|
|
982
|
+
...projectTodoCrossPlanDependencies(store.members).filter((edge) => fromIt(edge.from)).map((edge) => edge.to),
|
|
983
|
+
];
|
|
984
|
+
const byKey = new Map();
|
|
985
|
+
for (const ref of targets) {
|
|
986
|
+
const status = store.members.find(({ plan }) => plan.plan_key === ref.plan_key)
|
|
987
|
+
?.tasks.find(({ task_id: id }) => id === ref.task_id)?.status;
|
|
988
|
+
if (status !== undefined && status !== 'retired') {
|
|
989
|
+
byKey.set(`${ref.plan_key}\0${ref.task_id}`, { plan_key: ref.plan_key, task_id: ref.task_id, status });
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return [...byKey.entries()].sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0)).map(([, task]) => task);
|
|
821
993
|
}
|
|
822
994
|
|
|
823
995
|
async function retireTask({ repoRoot, env, planKey, taskId, reason }) {
|
|
@@ -828,14 +1000,25 @@ async function retireTask({ repoRoot, env, planKey, taskId, reason }) {
|
|
|
828
1000
|
// 未知のplan/taskはStoreの既存の拒否をそのまま通す。
|
|
829
1001
|
return mutate({ repoRoot, env, planKey, taskId, kind: 'retire', payload: { reason }, evidenceRef: null });
|
|
830
1002
|
}
|
|
831
|
-
if (state.status === 'retired')
|
|
1003
|
+
if (state.status === 'retired') {
|
|
1004
|
+
return unchangedTransition(store, { env, planKey, taskId, kind: 'retire', dropped: reasonDropped(reason) });
|
|
1005
|
+
}
|
|
1006
|
+
const dependents = retireDependents(store, member, taskId);
|
|
832
1007
|
const append = async () => {
|
|
1008
|
+
let result;
|
|
833
1009
|
try {
|
|
834
|
-
|
|
1010
|
+
result = await mutate({ repoRoot, env, planKey, taskId, kind: 'retire',
|
|
835
1011
|
payload: { reason, prior_status: state.status }, evidenceRef: null });
|
|
836
1012
|
} catch (error) {
|
|
837
1013
|
throw retireStateConflict(error, { planKey, taskId, priorStatus: state.status });
|
|
838
1014
|
}
|
|
1015
|
+
const { result_digest: _replaced, ...recorded } = result;
|
|
1016
|
+
const named = { ...recorded, dependents, ...(dependents.length === 0 ? {} : {
|
|
1017
|
+
next_action: `${dependents.map((task) => `${task.plan_key}/${task.task_id} (${task.status})`).join(', ')}`
|
|
1018
|
+
+ ` no longer wait on ${planKey}/${taskId}; see \`lattice todo status --json\`.`,
|
|
1019
|
+
}), result_digest: '' };
|
|
1020
|
+
named.result_digest = todoSelfDigest(named, 'result_digest');
|
|
1021
|
+
return named;
|
|
839
1022
|
};
|
|
840
1023
|
if (state.status !== 'in-progress') return append();
|
|
841
1024
|
// Runtime binds an intake to the latest literal start and ignores later done/reopen, so the
|
|
@@ -938,7 +1121,7 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
938
1121
|
.filter((task) => task.plan_key === planKey).map(({ task_id: id }) => id),
|
|
939
1122
|
self_unknowns: [{ kind: 'witness_missing', ref: unusable ?? 'no_independence_record' }],
|
|
940
1123
|
guidance: selectIndependenceGuidance({
|
|
941
|
-
coverage: 'missing', taskDeclared: false, taskStale: false, coordinationMode,
|
|
1124
|
+
coverage: 'missing', taskDeclared: false, taskStale: false, coordinationMode, planKey,
|
|
942
1125
|
}),
|
|
943
1126
|
};
|
|
944
1127
|
}
|
|
@@ -987,7 +1170,7 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
987
1170
|
conflictWithActive: conflictsWithActive[0]?.severability ?? null,
|
|
988
1171
|
conflictBetweenReady: readyConflict?.severability ?? null,
|
|
989
1172
|
verdictsAbsent: selfUnknowns.some(({ kind }) => kind === 'plan_verdicts_absent'),
|
|
990
|
-
coordinationMode,
|
|
1173
|
+
coordinationMode, planKey,
|
|
991
1174
|
}),
|
|
992
1175
|
};
|
|
993
1176
|
}
|
|
@@ -1019,7 +1202,7 @@ async function startTask({
|
|
|
1019
1202
|
});
|
|
1020
1203
|
}
|
|
1021
1204
|
const resolvedTaskId = readyTask?.task_id ?? taskMatches[0].task_id;
|
|
1022
|
-
const unchanged = unchangedTransition(store, { env, planKey, taskId: resolvedTaskId, kind: 'start' });
|
|
1205
|
+
const unchanged = await unchangedTransition(store, { env, planKey, taskId: resolvedTaskId, kind: 'start' });
|
|
1023
1206
|
if (unchanged !== null) return unchanged;
|
|
1024
1207
|
// noteはjournal appendより前に読む。壊れていてもstartは通す(ADR 0166 / 0181)。
|
|
1025
1208
|
let noteContext;
|
|
@@ -1069,7 +1252,8 @@ async function startTask({
|
|
|
1069
1252
|
// literal startだけを束縛に使いcarryを推定しないため、改訂を跨いだ進行中工程の
|
|
1070
1253
|
// 再開はこの入口だけが正規経路になる。advisory・independence gateは初回startで
|
|
1071
1254
|
// 済んでいるため再適用しない。
|
|
1072
|
-
|
|
1255
|
+
// actor: 改訂が運ぶstartの記録者。渡せば現在の席でなくその記録者でrebind startを積む(a16)。
|
|
1256
|
+
export async function rebindStart({ repoRoot, env, planKey, taskId, reason, actor = null }) {
|
|
1073
1257
|
const store = await readTodoStore({ repoRoot });
|
|
1074
1258
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
1075
1259
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active');
|
|
@@ -1101,7 +1285,7 @@ export async function rebindStart({ repoRoot, env, planKey, taskId, reason }) {
|
|
|
1101
1285
|
}
|
|
1102
1286
|
return mutate({
|
|
1103
1287
|
repoRoot, env, planKey, taskId, kind: 'start',
|
|
1104
|
-
payload: { start_mode: 'rebind', reason }, evidenceRef: null, noteContext,
|
|
1288
|
+
payload: { start_mode: 'rebind', reason }, evidenceRef: null, noteContext, actor,
|
|
1105
1289
|
});
|
|
1106
1290
|
}
|
|
1107
1291
|
|
|
@@ -1290,11 +1474,21 @@ async function dependencyRevision({
|
|
|
1290
1474
|
? [...desired.hard_dependencies, { from, to }]
|
|
1291
1475
|
: desired.hard_dependencies.filter((edge) => !(edge.from.task_id === fromTaskId
|
|
1292
1476
|
&& edge.to.task_id === toTaskId));
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1477
|
+
let applied;
|
|
1478
|
+
try {
|
|
1479
|
+
applied = await applyPlanRevision({
|
|
1480
|
+
repoRoot, env, input: { schema: 'lattice.plan_revise_input.v1', desired },
|
|
1481
|
+
notes: [{ task_id: fromTaskId,
|
|
1482
|
+
body: `dependency ${operation} ${fromTaskId}→${toTaskId}: ${reason}` }],
|
|
1483
|
+
});
|
|
1484
|
+
} catch (error) {
|
|
1485
|
+
// a18: the new edge closes a cycle; nothing stored is inconsistent, so name the edge and the path.
|
|
1486
|
+
if (operation === 'connect' && error instanceof TodoStoreError && error.detail?.reason === 'merged_cycle') {
|
|
1487
|
+
throw new TodoStoreError('DEPENDENCY_CYCLE', 'dependency_cycle', undefined, {
|
|
1488
|
+
from, to, cycle: error.detail.cycle ?? null });
|
|
1489
|
+
}
|
|
1490
|
+
throw error;
|
|
1491
|
+
}
|
|
1298
1492
|
const result = {
|
|
1299
1493
|
schema: 'lattice.todo_dependency_revision_result.v1', project_id: store.project_id,
|
|
1300
1494
|
plan_key: planKey, operation, from, to, reason, actor: desired.actor,
|
|
@@ -1421,11 +1615,20 @@ async function dependencyDisconnectLedger({
|
|
|
1421
1615
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId
|
|
1422
1616
|
));
|
|
1423
1617
|
if (live.length === 0) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1618
|
+
const from = { plan_key: fromPlanKey, task_id: fromTaskId };
|
|
1619
|
+
const to = { plan_key: toPlanKey, task_id: toTaskId };
|
|
1620
|
+
if (fromPlanKey === toPlanKey) {
|
|
1621
|
+
const member = store.members.find(({ plan }) => plan.plan_key === toPlanKey);
|
|
1622
|
+
const predecessors = (member?.plan.hard_dependencies ?? [])
|
|
1623
|
+
.filter((edge) => edge.to.task_id === toTaskId).map((edge) => edge.from.task_id).sort();
|
|
1624
|
+
throw new TodoStoreError('DEPENDENCY_NOT_FOUND', 'dependency_not_found', undefined, {
|
|
1625
|
+
from, to, predecessors,
|
|
1626
|
+
next_action: `${toPlanKey} has no dependency ${fromTaskId} -> ${toTaskId}`
|
|
1627
|
+
+ ` (${toTaskId} depends on ${predecessors.length === 0 ? 'nothing in this plan' : predecessors.join(', ')});`
|
|
1628
|
+
+ ` see \`lattice plan show ${toPlanKey} --json\`.`,
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
throw new TodoStoreError('DEPENDENCY_NOT_FOUND', 'cross_plan_dependency_not_found', undefined, { from, to });
|
|
1429
1632
|
}
|
|
1430
1633
|
const [target] = live;
|
|
1431
1634
|
const owner = store.members.find((member) => (member.plan_scoped?.events ?? [])
|
|
@@ -2867,7 +3070,7 @@ async function independenceCompile({ repoRoot, planKey, inputRef }) {
|
|
|
2867
3070
|
{
|
|
2868
3071
|
plan_key: planKey,
|
|
2869
3072
|
missing_task_ids: missingReady,
|
|
2870
|
-
next_action:
|
|
3073
|
+
next_action: independenceCompileCommand(planKey),
|
|
2871
3074
|
},
|
|
2872
3075
|
);
|
|
2873
3076
|
}
|
|
@@ -3035,7 +3238,7 @@ async function independence({ repoRoot, requestedPlanKey }) {
|
|
|
3035
3238
|
conflictBetweenReady: projected.frontier.serialize_pairs[0]?.severability ?? null,
|
|
3036
3239
|
// 案内の正本は1つ(ADR 0130 Decision 1)。着手する人と読みに来た人が同じ状況について
|
|
3037
3240
|
// 違う文言を受け取らないよう、調整方式もここへ渡す。
|
|
3038
|
-
coordinationMode: member?.coordination?.mode ?? null,
|
|
3241
|
+
coordinationMode: member?.coordination?.mode ?? null, planKey,
|
|
3039
3242
|
verdictsAbsent: projected.frontier.unknown
|
|
3040
3243
|
.some(({ unknowns }) => unknowns.some(({ kind }) => kind === 'plan_verdicts_absent')),
|
|
3041
3244
|
}),
|
|
@@ -3099,6 +3302,8 @@ async function seamProfile({ repoRoot, planKey, filePath }) {
|
|
|
3099
3302
|
return profile;
|
|
3100
3303
|
}
|
|
3101
3304
|
|
|
3305
|
+
const independenceCompileCommand = (planKey, input = '<file>') => `lattice todo independence compile --plan ${planKey} --input ${input}`;
|
|
3306
|
+
|
|
3102
3307
|
async function seamProposalCompile({ repoRoot, planKey }) {
|
|
3103
3308
|
const currentBaseSha = currentHeadSha(repoRoot);
|
|
3104
3309
|
const store = await readTodoStore({ repoRoot });
|
|
@@ -3114,31 +3319,31 @@ async function seamProposalCompile({ repoRoot, planKey }) {
|
|
|
3114
3319
|
'SEAM_PROPOSAL_COMPILE_UNAVAILABLE',
|
|
3115
3320
|
independenceArtifact === null ? 'independence_artifact_absent' : 'independence_artifact_superseded',
|
|
3116
3321
|
undefined,
|
|
3117
|
-
{ next_action:
|
|
3322
|
+
{ next_action: independenceCompileCommand(planKey) },
|
|
3118
3323
|
);
|
|
3119
3324
|
}
|
|
3120
3325
|
if (independenceArtifact.outcome !== 'compiled') {
|
|
3121
3326
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'independence_outcome_not_compiled', undefined, {
|
|
3122
3327
|
outcome: independenceArtifact.outcome,
|
|
3123
|
-
next_action:
|
|
3328
|
+
next_action: independenceCompileCommand(planKey),
|
|
3124
3329
|
});
|
|
3125
3330
|
}
|
|
3126
3331
|
if (independenceArtifact.base_sha !== currentBaseSha) {
|
|
3127
3332
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'independence_artifact_stale', undefined, {
|
|
3128
3333
|
independence_base_sha: independenceArtifact.base_sha,
|
|
3129
3334
|
current_base_sha: currentBaseSha,
|
|
3130
|
-
next_action:
|
|
3335
|
+
next_action: independenceCompileCommand(planKey),
|
|
3131
3336
|
});
|
|
3132
3337
|
}
|
|
3133
3338
|
const witnessSet = await readTodoWitnessSet({ repoRoot, planKey });
|
|
3134
3339
|
if (witnessSet === null) {
|
|
3135
3340
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'witness_set_absent', undefined, {
|
|
3136
|
-
next_action:
|
|
3341
|
+
next_action: independenceCompileCommand(planKey),
|
|
3137
3342
|
});
|
|
3138
3343
|
}
|
|
3139
3344
|
if (witnessSet.witness_set_digest !== independenceArtifact.witness_set_digest) {
|
|
3140
3345
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'witness_set_changed', undefined, {
|
|
3141
|
-
next_action:
|
|
3346
|
+
next_action: independenceCompileCommand(planKey),
|
|
3142
3347
|
});
|
|
3143
3348
|
}
|
|
3144
3349
|
|
|
@@ -3235,7 +3440,7 @@ async function witnessScaffold({ repoRoot, planKey, inputRef }) {
|
|
|
3235
3440
|
observed_paths: paths,
|
|
3236
3441
|
task_count: Object.keys(witnessSet.manual_witness).length,
|
|
3237
3442
|
witness_set_digest: witnessSet.witness_set_digest,
|
|
3238
|
-
next_action:
|
|
3443
|
+
next_action: independenceCompileCommand(planKey, ref),
|
|
3239
3444
|
};
|
|
3240
3445
|
}
|
|
3241
3446
|
|
|
@@ -3279,13 +3484,13 @@ async function seamProposalApply({ repoRoot, planKey, pathNames = {}, land = fal
|
|
|
3279
3484
|
const artifact = await readTodoSeamProposalArtifact({ repoRoot, store, planKey });
|
|
3280
3485
|
if (artifact === null) {
|
|
3281
3486
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'seam_proposal_absent', undefined, {
|
|
3282
|
-
plan_key: planKey, next_action:
|
|
3487
|
+
plan_key: planKey, next_action: `lattice todo seam-proposal compile --plan ${planKey}`,
|
|
3283
3488
|
});
|
|
3284
3489
|
}
|
|
3285
3490
|
const witnessSet = await readTodoWitnessSet({ repoRoot, planKey });
|
|
3286
3491
|
if (witnessSet === null) {
|
|
3287
3492
|
throw new TodoStoreError('SEAM_PROPOSAL_COMPILE_UNAVAILABLE', 'witness_set_absent', undefined, {
|
|
3288
|
-
plan_key: planKey, next_action:
|
|
3493
|
+
plan_key: planKey, next_action: independenceCompileCommand(planKey),
|
|
3289
3494
|
});
|
|
3290
3495
|
}
|
|
3291
3496
|
const baseArtifact = await readTodoIndependenceArtifact({ repoRoot, store, planKey });
|
|
@@ -3415,6 +3620,7 @@ async function seamProposal({ repoRoot, requestedPlanKey }) {
|
|
|
3415
3620
|
guidance: selectSeamProposalGuidance({
|
|
3416
3621
|
coverage,
|
|
3417
3622
|
unknownKinds: components.flatMap(({ unknowns }) => unknowns.map(({ kind }) => kind)),
|
|
3623
|
+
planKey,
|
|
3418
3624
|
}),
|
|
3419
3625
|
component_count: artifact === null ? null : components.length,
|
|
3420
3626
|
conflict_resource_count: artifact === null ? null : components
|
|
@@ -3650,7 +3856,7 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3650
3856
|
plan_key: planKey,
|
|
3651
3857
|
coverage: 'superseded',
|
|
3652
3858
|
unreadable_reason: `${error.code}:${error.detail?.reason ?? error.message}`,
|
|
3653
|
-
guidance: selectSeamProposalGuidance({ coverage: 'superseded' }),
|
|
3859
|
+
guidance: selectSeamProposalGuidance({ coverage: 'superseded', planKey }),
|
|
3654
3860
|
component_count: null,
|
|
3655
3861
|
conflict_resource_count: null,
|
|
3656
3862
|
components: [],
|
|
@@ -3663,7 +3869,7 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3663
3869
|
plan_key: planKey,
|
|
3664
3870
|
coverage: 'missing',
|
|
3665
3871
|
unreadable_reason: null,
|
|
3666
|
-
guidance: selectSeamProposalGuidance({ coverage: 'missing' }),
|
|
3872
|
+
guidance: selectSeamProposalGuidance({ coverage: 'missing', planKey }),
|
|
3667
3873
|
component_count: null,
|
|
3668
3874
|
conflict_resource_count: null,
|
|
3669
3875
|
components: [],
|
|
@@ -3699,7 +3905,7 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3699
3905
|
plan_key: planKey,
|
|
3700
3906
|
coverage,
|
|
3701
3907
|
unreadable_reason: unreadableReason,
|
|
3702
|
-
guidance: selectSeamProposalGuidance({ coverage }),
|
|
3908
|
+
guidance: selectSeamProposalGuidance({ coverage, planKey }),
|
|
3703
3909
|
component_count: components.length,
|
|
3704
3910
|
conflict_resource_count: components
|
|
3705
3911
|
.reduce((count, component) => count + component.conflicts.length, 0),
|
|
@@ -4059,9 +4265,9 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4059
4265
|
meaning: 'source_inventory_verification_state',
|
|
4060
4266
|
lifecycle_blocked: false,
|
|
4061
4267
|
dashboard_visibility_blocked: false,
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4268
|
+
// registered_unreconciledは何もしなくてよい状態(a22)。次の軽い改訂がreconciledにする。
|
|
4269
|
+
schema_command: null,
|
|
4270
|
+
next_action: reconciled ? null : 'none',
|
|
4065
4271
|
},
|
|
4066
4272
|
};
|
|
4067
4273
|
});
|
|
@@ -4092,6 +4298,21 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4092
4298
|
return result;
|
|
4093
4299
|
}
|
|
4094
4300
|
|
|
4301
|
+
// `todo verify`の人間向け1行。--jsonと同じresultから導く(verifyは不整合を例外で拒否するので、
|
|
4302
|
+
// ここへ届くのは検証が通った結果だけ。注意が要るのはsnapshot古さとcommit前の証拠)。
|
|
4303
|
+
function verifyVerdictLine(result) {
|
|
4304
|
+
const members = result.verified_members.map((member) => `${member.plan_key} ${member.reconciliation_state}${
|
|
4305
|
+
member.reconciliation_state === 'reconciled' ? '' : ', nothing to do'}`);
|
|
4306
|
+
const notes = [];
|
|
4307
|
+
if (result.snapshot_stale) notes.push('snapshot stale');
|
|
4308
|
+
if (result.uncommitted_evidence.length > 0) {
|
|
4309
|
+
notes.push(`${result.uncommitted_evidence.length} uncommitted evidence (commit it, then rerun)`);
|
|
4310
|
+
}
|
|
4311
|
+
const count = result.verified_members.length;
|
|
4312
|
+
return `todo verify: ${notes.length === 0 ? 'ok' : 'attention'}, ${count} plan${count === 1 ? '' : 's'} verified`
|
|
4313
|
+
+ `${notes.map((note) => `, ${note}`).join('')} (${members.join('; ')})`;
|
|
4314
|
+
}
|
|
4315
|
+
|
|
4095
4316
|
async function rebuildSnapshot({ repoRoot, planKey }) {
|
|
4096
4317
|
// Read first so every typed validation failure happens before the rebuild writer is entered.
|
|
4097
4318
|
const store = await readTodoStore({ repoRoot });
|
|
@@ -4189,6 +4410,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4189
4410
|
|
|
4190
4411
|
const automatedStructureRealize = parseAutomatedStructureRealizeArgs(argv);
|
|
4191
4412
|
let action = null;
|
|
4413
|
+
let plainVerify = false; // a19: `todo verify`は--jsonが無ければ1行の判定だけを返す
|
|
4192
4414
|
if (argv.length === 2 && argv[0] === 'repair-eol' && argv[1] === '--json') {
|
|
4193
4415
|
// 壊れたstoreを読めない時の入口なので、dashboard所有権pre-hookを通さない。
|
|
4194
4416
|
action = (repoRoot) => repairStoreEol({ repoRoot });
|
|
@@ -4221,10 +4443,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4221
4443
|
&& (argv.length === 3 || argv[3] === '--json')) {
|
|
4222
4444
|
action = (repoRoot) => bindings({ repoRoot, requestedPlanKey: argv[2] });
|
|
4223
4445
|
} else if (argv[0] === 'note' && argv[1] !== 'list') {
|
|
4224
|
-
const flags = matchFlagCommand(argv, ['note'],
|
|
4225
|
-
known: ['plan', 'task', 'message', 'input', 'supersedes'],
|
|
4226
|
-
required: ['plan'],
|
|
4227
|
-
});
|
|
4446
|
+
const flags = matchFlagCommand(argv, ['note'], NOTE_FLAG_SPEC);
|
|
4228
4447
|
const hasMessage = typeof flags?.message === 'string' && flags.message.length > 0;
|
|
4229
4448
|
const hasInput = isAuthoringPathToken(flags?.input);
|
|
4230
4449
|
if (flags !== null && isTodoIdentifier(flags.plan)
|
|
@@ -4255,25 +4474,19 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4255
4474
|
action = (repoRoot) => independenceMode({
|
|
4256
4475
|
repoRoot, env, planKey: argv[3], mode: argv[5], reason: argv[7],
|
|
4257
4476
|
});
|
|
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) {
|
|
4477
|
+
} else if (argv[0] === 'dependency' && argv[1] === 'connect'
|
|
4478
|
+
&& dependencyFlags(argv) !== null) {
|
|
4479
|
+
const flags = dependencyFlags(argv);
|
|
4264
4480
|
action = (repoRoot) => dependencyConnect({
|
|
4265
|
-
repoRoot, env, fromPlanKey:
|
|
4266
|
-
toPlanKey:
|
|
4481
|
+
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
4482
|
+
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
4267
4483
|
});
|
|
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) {
|
|
4484
|
+
} else if (argv[0] === 'dependency' && argv[1] === 'disconnect'
|
|
4485
|
+
&& dependencyFlags(argv) !== null) {
|
|
4486
|
+
const flags = dependencyFlags(argv);
|
|
4274
4487
|
action = (repoRoot) => dependencyDisconnect({
|
|
4275
|
-
repoRoot, env, fromPlanKey:
|
|
4276
|
-
toPlanKey:
|
|
4488
|
+
repoRoot, env, fromPlanKey: flags['from-plan'], fromTaskId: flags['from-task'],
|
|
4489
|
+
toPlanKey: flags['to-plan'], toTaskId: flags['to-task'], reason: flags.reason,
|
|
4277
4490
|
});
|
|
4278
4491
|
} else if (argv[0] === 'independence' && argv[1] === 'compile') {
|
|
4279
4492
|
const flags = matchFlagCommand(argv, ['independence', 'compile'], {
|
|
@@ -4367,10 +4580,12 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4367
4580
|
action = (repoRoot) => seamProposal({ repoRoot, requestedPlanKey: argv[2] });
|
|
4368
4581
|
} else if ((argv.length === 1 && argv[0] === 'verify')
|
|
4369
4582
|
|| (argv.length === 2 && argv[0] === 'verify' && argv[1] === '--json')) {
|
|
4583
|
+
plainVerify = argv.length === 1;
|
|
4370
4584
|
action = (repoRoot) => verify({ repoRoot, requestedPlanKey: null });
|
|
4371
4585
|
} else if ((argv.length === 3 || argv.length === 4) && argv[0] === 'verify'
|
|
4372
4586
|
&& argv[1] === '--plan' && isTodoIdentifier(argv[2])
|
|
4373
4587
|
&& (argv.length === 3 || argv[3] === '--json')) {
|
|
4588
|
+
plainVerify = argv.length === 3;
|
|
4374
4589
|
action = (repoRoot) => verify({ repoRoot, requestedPlanKey: argv[2] });
|
|
4375
4590
|
} else if (argv.length === 4 && argv[0] === 'snapshot' && argv[1] === '--rebuild'
|
|
4376
4591
|
&& argv[2] === '--plan' && isTodoIdentifier(argv[3])) {
|
|
@@ -4412,9 +4627,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4412
4627
|
action = (repoRoot) => revise({ repoRoot, env, planKey: flags.plan, inputRef: flags.input });
|
|
4413
4628
|
}
|
|
4414
4629
|
} else if (argv[0] === 'split') {
|
|
4415
|
-
const flags = matchFlagCommand(argv, ['split'],
|
|
4416
|
-
known: ['plan', 'input'], required: ['plan', 'input'],
|
|
4417
|
-
});
|
|
4630
|
+
const flags = matchFlagCommand(argv, ['split'], TODO_FLAG_SPECS.split);
|
|
4418
4631
|
if (flags !== null && isTodoIdentifier(flags.plan) && isAuthoringPathToken(flags.input)) {
|
|
4419
4632
|
action = (repoRoot) => splitTodo({ repoRoot, env, planKey: flags.plan, inputRef: flags.input });
|
|
4420
4633
|
}
|
|
@@ -4435,12 +4648,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4435
4648
|
} else if (argv.length === 4 && argv[0] === 'phase' && argv[1] === 'status'
|
|
4436
4649
|
&& argv[2] === '--plan' && isTodoIdentifier(argv[3])) {
|
|
4437
4650
|
action = (repoRoot) => phaseStatus({ repoRoot, planKey: argv[3] });
|
|
4438
|
-
} else if (argv
|
|
4439
|
-
&& argv
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
kind: 'phase_review', payload: { reason: argv[7] } });
|
|
4651
|
+
} else if (argv[0] === 'phase' && argv[1] === 'review'
|
|
4652
|
+
&& phaseReasonFlags(argv) !== null) {
|
|
4653
|
+
const flags = phaseReasonFlags(argv);
|
|
4654
|
+
action = (repoRoot) => phaseMutation({ repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
|
|
4655
|
+
kind: 'phase_review', payload: { reason: flags.reason } });
|
|
4444
4656
|
} else if (argv[0] === 'phase' && ['accept', 'reject'].includes(argv[1])) {
|
|
4445
4657
|
const outcome = argv[1];
|
|
4446
4658
|
const flags = matchFlagCommand(argv, ['phase', outcome], {
|
|
@@ -4467,23 +4679,18 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4467
4679
|
&& (argv.length === 8 || (argv[8] === '--override-reason' && argv[9].length > 0))) {
|
|
4468
4680
|
action = (repoRoot) => phaseMutation({ repoRoot, env, planKey: argv[3], phaseId: argv[5],
|
|
4469
4681
|
kind: 'phase_reopen', payload: { reason: argv[7], override_reason: argv[9] ?? null } });
|
|
4470
|
-
} else if (argv
|
|
4471
|
-
&& argv
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
kind: 'phase_close_unaudited', payload: { reason: argv[7] } });
|
|
4682
|
+
} else if (argv[0] === 'phase' && argv[1] === 'close-unaudited'
|
|
4683
|
+
&& phaseReasonFlags(argv) !== null) {
|
|
4684
|
+
const flags = phaseReasonFlags(argv);
|
|
4685
|
+
action = (repoRoot) => phaseMutation({ repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
|
|
4686
|
+
kind: 'phase_close_unaudited', payload: { reason: flags.reason } });
|
|
4476
4687
|
} else if (argv.length >= 4 && argv[0] === 'phase' && argv[1] === 'baseline'
|
|
4477
4688
|
&& argv[2] === '--reason' && argv[3].length > 0
|
|
4478
4689
|
&& parseBaselineExceptFlags(argv.slice(4)) !== null) {
|
|
4479
4690
|
const exceptPlanKeys = parseBaselineExceptFlags(argv.slice(4));
|
|
4480
4691
|
action = (repoRoot) => phaseBaseline({ repoRoot, env, reason: argv[3], exceptPlanKeys });
|
|
4481
4692
|
} 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
|
-
});
|
|
4693
|
+
const flags = matchFlagCommand(argv, ['start'], TODO_FLAG_SPECS.start);
|
|
4487
4694
|
if (flags !== null && flags.rebind === true) {
|
|
4488
4695
|
if (isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)
|
|
4489
4696
|
&& typeof flags.reason === 'string' && flags.reason.length > 0) {
|
|
@@ -4501,70 +4708,45 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4501
4708
|
}
|
|
4502
4709
|
} else if (argv[0] === 'done') {
|
|
4503
4710
|
const flags = matchFlagCommand(argv, ['done'], DONE_FLAG_SPEC);
|
|
4504
|
-
const hasEvidence = isAuthoringPathToken(flags?.evidence);
|
|
4505
|
-
const hasMessage = typeof flags?.message === 'string' && flags.message.length > 0;
|
|
4506
4711
|
// u03 A58: both, one or neither of --evidence/--message is accepted.
|
|
4507
4712
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)
|
|
4508
|
-
&& (flags.evidence === undefined ||
|
|
4713
|
+
&& (flags.evidence === undefined || isAuthoringPathToken(flags.evidence))
|
|
4509
4714
|
&& (flags['test-result'] === undefined || isAuthoringPathToken(flags['test-result']))) {
|
|
4510
4715
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4511
|
-
kind: 'done',
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
planKey: flags.plan, taskId: flags.task,
|
|
4518
|
-
});
|
|
4519
|
-
evidenceMessage = `${flags.message}\n\nevidence: ${file.repo_id}:${file.path}`
|
|
4520
|
-
+ ` (git blob ${file.git_blob_oid}, sha256 ${file.content_digest})\n`;
|
|
4521
|
-
} else if (!hasEvidence && !hasMessage) {
|
|
4522
|
-
evidenceMessage = DONE_WITHOUT_EVIDENCE_MESSAGE;
|
|
4523
|
-
}
|
|
4524
|
-
return mutate({
|
|
4525
|
-
repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4526
|
-
kind: 'done', payload: 'authored',
|
|
4527
|
-
evidenceRef: evidenceMessage === null ? flags.evidence : null,
|
|
4528
|
-
evidenceMessage,
|
|
4529
|
-
testResultRef: flags['test-result'] ?? null,
|
|
4530
|
-
});
|
|
4531
|
-
} });
|
|
4716
|
+
kind: 'done', dropped: (recorded) => doneDropped({ repoRoot, flags, recorded }),
|
|
4717
|
+
action: async () => mutate({
|
|
4718
|
+
repoRoot, env, planKey: flags.plan, taskId: flags.task, kind: 'done', payload: 'authored',
|
|
4719
|
+
...await doneEvidenceInput({ repoRoot, flags }),
|
|
4720
|
+
testResultRef: flags['test-result'] ?? null,
|
|
4721
|
+
}) });
|
|
4532
4722
|
}
|
|
4533
4723
|
}
|
|
4534
4724
|
if (action === null && argv[0] === 'retract') {
|
|
4535
|
-
const flags = matchFlagCommand(argv, ['retract'],
|
|
4536
|
-
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4537
|
-
});
|
|
4725
|
+
const flags = matchFlagCommand(argv, ['retract'], TODO_FLAG_SPECS.retract);
|
|
4538
4726
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4539
4727
|
action = (repoRoot) => retractStart({
|
|
4540
4728
|
repoRoot, env, planKey: flags.plan, taskId: flags.task, reason: flags.reason,
|
|
4541
4729
|
});
|
|
4542
4730
|
}
|
|
4543
4731
|
} else if (argv[0] === 'block') {
|
|
4544
|
-
const flags = matchFlagCommand(argv, ['block'],
|
|
4545
|
-
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4546
|
-
});
|
|
4732
|
+
const flags = matchFlagCommand(argv, ['block'], TODO_FLAG_SPECS.block);
|
|
4547
4733
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4548
4734
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4549
|
-
kind: 'block', action: () => mutate({
|
|
4735
|
+
kind: 'block', dropped: reasonDropped(flags.reason), action: () => mutate({
|
|
4550
4736
|
repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4551
4737
|
kind: 'block', payload: { reason: flags.reason }, evidenceRef: null,
|
|
4552
4738
|
}) });
|
|
4553
4739
|
}
|
|
4554
4740
|
} else if (argv[0] === 'retire') {
|
|
4555
4741
|
// 恒久除去(2026-08-29オーナー裁定)。planの形は変えず、状態遷移として工程を閉じる。
|
|
4556
|
-
const flags = matchFlagCommand(argv, ['retire'],
|
|
4557
|
-
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4558
|
-
});
|
|
4742
|
+
const flags = matchFlagCommand(argv, ['retire'], TODO_FLAG_SPECS.retire);
|
|
4559
4743
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4560
4744
|
action = (repoRoot) => retireTask({
|
|
4561
4745
|
repoRoot, env, planKey: flags.plan, taskId: flags.task, reason: flags.reason,
|
|
4562
4746
|
});
|
|
4563
4747
|
}
|
|
4564
4748
|
} else if (argv[0] === 'unblock') {
|
|
4565
|
-
const flags = matchFlagCommand(argv, ['unblock'],
|
|
4566
|
-
known: ['plan', 'task'], required: ['plan', 'task'],
|
|
4567
|
-
});
|
|
4749
|
+
const flags = matchFlagCommand(argv, ['unblock'], TODO_FLAG_SPECS.unblock);
|
|
4568
4750
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4569
4751
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4570
4752
|
kind: 'unblock', action: () => mutate({
|
|
@@ -4584,10 +4766,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4584
4766
|
});
|
|
4585
4767
|
}
|
|
4586
4768
|
} else if (argv[0] === 'reopen') {
|
|
4587
|
-
const flags = matchFlagCommand(argv, ['reopen'],
|
|
4588
|
-
known: ['plan', 'task', 'reason', 'override-reason'],
|
|
4589
|
-
required: ['plan', 'task', 'reason'],
|
|
4590
|
-
});
|
|
4769
|
+
const flags = matchFlagCommand(argv, ['reopen'], TODO_FLAG_SPECS.reopen);
|
|
4591
4770
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)
|
|
4592
4771
|
&& (flags['override-reason'] === undefined
|
|
4593
4772
|
|| (typeof flags['override-reason'] === 'string' && flags['override-reason'].length > 0))) {
|
|
@@ -4642,7 +4821,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4642
4821
|
const result = atomicCommit
|
|
4643
4822
|
? await commitTodoStoreMutation({ repoRoot, argv, action, env })
|
|
4644
4823
|
: await action(repoRoot);
|
|
4645
|
-
if (result !== null) stdout.write(`${JSON.stringify(result)}\n`);
|
|
4824
|
+
if (result !== null) stdout.write(`${plainVerify ? verifyVerdictLine(result) : JSON.stringify(result)}\n`);
|
|
4646
4825
|
return 0;
|
|
4647
4826
|
} catch (error) {
|
|
4648
4827
|
if (error instanceof TodoStoreError || (typeof error?.code === 'string'
|