@quolu/lattice 0.85.0 → 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/bin/lattice.mjs +31 -16
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +1 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +1 -1
- package/package.json +1 -1
- package/src/cli-help.mjs +8 -1
- package/src/cli-refusal-guidance.mjs +26 -0
- package/src/project-cli.mjs +5 -4
- package/src/setup-cli.mjs +3 -1
- package/src/todo-authoring-input.mjs +14 -6
- package/src/todo-cli.mjs +150 -90
package/bin/lattice.mjs
CHANGED
|
@@ -97,17 +97,6 @@ if (help !== null) {
|
|
|
97
97
|
} catch (error) {
|
|
98
98
|
process.exitCode = projectCliFailure(process.stderr, error);
|
|
99
99
|
}
|
|
100
|
-
} else if (args.length === 7 && args[0] === 'plan' && args[1] === 'scope-review'
|
|
101
|
-
&& args[2] === '--plan-input' && args[4] === '--review' && args[6] === '--json') {
|
|
102
|
-
const { runPlanScopeReview } = await import('../src/plan-scope-review.mjs');
|
|
103
|
-
const { projectCliFailure } = await import('../src/project-cli.mjs');
|
|
104
|
-
try {
|
|
105
|
-
process.exitCode = await runPlanScopeReview({
|
|
106
|
-
cwd: process.cwd(), planInputRef: args[3], reviewRef: args[5], stdout: process.stdout,
|
|
107
|
-
});
|
|
108
|
-
} catch (error) {
|
|
109
|
-
process.exitCode = projectCliFailure(process.stderr, error);
|
|
110
|
-
}
|
|
111
100
|
} else if (args.length === 4 && args[0] === 'plan' && args[1] === 'scope-review'
|
|
112
101
|
&& args[2] === '--schema' && args[3] === '--json') {
|
|
113
102
|
const { runPlanScopeReviewSchema } = await import('../src/plan-scope-review.mjs');
|
|
@@ -117,6 +106,25 @@ if (help !== null) {
|
|
|
117
106
|
} catch (error) {
|
|
118
107
|
process.exitCode = projectCliFailure(process.stderr, error);
|
|
119
108
|
}
|
|
109
|
+
} else if (args[0] === 'plan' && args[1] === 'scope-review') {
|
|
110
|
+
// 引数違反も欄と直し方をtypedに返す(a22)。素の`plan scope-review`をusage文1行で落とさない。
|
|
111
|
+
const { matchFlagCommand } = await import('../src/todo-authoring-input.mjs');
|
|
112
|
+
const spec = { known: ['plan-input', 'review', 'json'], required: ['plan-input', 'review'], booleans: ['json'] };
|
|
113
|
+
const flags = matchFlagCommand(args, ['plan', 'scope-review'], spec);
|
|
114
|
+
if (flags === null || flags.json !== true) {
|
|
115
|
+
const { planArgumentFailure } = await import('../src/project-cli.mjs');
|
|
116
|
+
process.exitCode = planArgumentFailure(process.stderr, args, spec);
|
|
117
|
+
} else {
|
|
118
|
+
const { runPlanScopeReview } = await import('../src/plan-scope-review.mjs');
|
|
119
|
+
const { projectCliFailure } = await import('../src/project-cli.mjs');
|
|
120
|
+
try {
|
|
121
|
+
process.exitCode = await runPlanScopeReview({
|
|
122
|
+
cwd: process.cwd(), planInputRef: flags['plan-input'], reviewRef: flags.review, stdout: process.stdout,
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
process.exitCode = projectCliFailure(process.stderr, error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
120
128
|
} else if (args.length === 4 && args[0] === 'plan' && args[1] === 'revise'
|
|
121
129
|
&& args[2] === '--schema' && args[3] === '--json') {
|
|
122
130
|
const { planReviseSchema } = await import('../src/plan-revise.mjs');
|
|
@@ -276,12 +284,19 @@ function observeInternalFailure(error, commandKind) {
|
|
|
276
284
|
}).catch(() => {});
|
|
277
285
|
}
|
|
278
286
|
|
|
279
|
-
// These
|
|
287
|
+
// These commands only ever print JSON, so a missing --json is implied (a20, a24). Plan writes are
|
|
288
|
+
// (revise, backchain) implied only once --input carries a value, so a missing --input is still named as such.
|
|
280
289
|
function withImpliedJson(argv) {
|
|
281
|
-
if (argv.includes('--json') || argv.
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
290
|
+
if (argv.includes('--json') || argv.includes('--help') || argv.includes('-h')) return argv;
|
|
291
|
+
const [command, sub] = argv;
|
|
292
|
+
const bare = !argv.some((word) => word.startsWith('-'));
|
|
293
|
+
const input = argv.indexOf('--input');
|
|
294
|
+
const implied = (bare && argv.length === 1 && (command === 'status' || command === 'session-context'))
|
|
295
|
+
|| (bare && argv.length === 3 && command === 'plan' && sub === 'show')
|
|
296
|
+
|| (bare && command === 'sensor' && (sub === 'init' || sub === 'sync') && argv.length <= 3)
|
|
297
|
+
|| (command === 'sensor' && sub === 'diff')
|
|
298
|
+
|| (command === 'plan' && (sub === 'revise' || sub === 'backchain')
|
|
299
|
+
&& input > 1 && typeof argv[input + 1] === 'string' && !argv[input + 1].startsWith('-'));
|
|
285
300
|
return implied ? [...argv, '--json'] : argv;
|
|
286
301
|
}
|
|
287
302
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon/Lattice/blob/main/docs/schemas/lattice.plan_create_input.v4.schema.json",
|
|
4
4
|
"title": "lattice.plan_create_input.v4",
|
|
5
|
-
"description": "Canonical initial authoring input for a phase-audited plan. Every task
|
|
5
|
+
"description": "Canonical initial authoring input for a phase-audited plan. Every task carries a design memo; an omitted, null or blank one is recorded as `NO_PLAN`. After the complete plan is written, run `lattice plan scope-review --plan-input <file> --review <scope-review.json> --json` (the review input: `lattice plan scope-review --schema --json`) and confirm that every task preserves an owner-supplied work specification without adding a product purpose. あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください actor, recorded_at, input_digest and tasks[].design_memo may be omitted: the machine fills the seat actor, the current time and NO_PLAN, recomputes input_digest and sorts every list into canonical order.",
|
|
6
6
|
"$comment": "Runtime validation additionally enforces canonical JSON+LF bytes, sorted identifiers and edges, unique ids, combined task/phase acyclicity, byte bounds, non-empty design_memo (omitted, null or blank becomes NO_PLAN), and input_digest (recomputed). tasks, hard_dependencies, joins, phases and phase_accept_dependencies are sorted into canonical order and exact duplicates dropped before validation.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon/Lattice/blob/main/docs/schemas/lattice.plan_create_input.v5.schema.json",
|
|
4
4
|
"title": "lattice.plan_create_input.v5",
|
|
5
|
-
"description": "Canonical initial authoring input for a phase-audited plan. Every task
|
|
5
|
+
"description": "Canonical initial authoring input for a phase-audited plan. Every task carries a design memo; an omitted, null or blank one is recorded as `NO_PLAN`. After the complete plan is written, run `lattice plan scope-review --plan-input <file> --review <scope-review.json> --json` (the review input: `lattice plan scope-review --schema --json`) and confirm that every task preserves an owner-supplied work specification without adding a product purpose. あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください v5 adds the per-task authored `done_condition`: plain text (or null when the author states none) that Lattice records and shows but never evaluates, never assigns and never records as done. Builds lattice.todo_plan.v8. The author writes intent: ids, titles, phases and edges (see `lattice plan create --template --json`). Every key whose value is constant or null may be omitted and the machine fills it: schema (this version), project_id (the store's project id; with no store yet, the repository directory name as a lower-case identifier; a different value is refused as project_id_mismatch), plan_version (v1; `lattice plan revise` uses the active plan's), actor (the seat actor), recorded_at (the current time; an ISO-8601 date-time with an explicit zone is normalised to UTC milliseconds), input_digest (recomputed), tasks[].design_memo (NO_PLAN), tasks[].lane (main), tasks[].narrative_ref, narrative_anchor, compile_binding, parent_task_id and done_condition (null), phases[].gate_policy (heavy), phases[].predecessor_phase_ids ([]), phases[].required_evidence_slots ([\"acceptance\"]), hard_dependencies, joins and phase_accept_dependencies ([]), and project_id/plan_key of an edge reference (this input's own). Every list is sorted into canonical order. A refusal lists every problem at once in detail.problems. Edge direction: from is the prerequisite; to starts after from is done.",
|
|
6
6
|
"$comment": "Runtime validation additionally enforces canonical JSON+LF bytes, sorted identifiers and edges, unique ids, combined task/phase acyclicity, byte bounds, non-empty design_memo (omitted, null or blank becomes NO_PLAN), and input_digest (recomputed). v5 additionally accepts hard_dependencies, joins, each joins[].after, phase_accept_dependencies, phases, phases[].predecessor_phase_ids and phases[].required_evidence_slots in any order or with exact duplicates: they are sorted into canonical order and de-duplicated before validation. tasks are sorted by task_id. Entries with the same key but different content are still refused.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.1",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
package/src/cli-help.mjs
CHANGED
|
@@ -36,6 +36,9 @@ Commands:
|
|
|
36
36
|
backchain --input <file> [--dry-run] --json
|
|
37
37
|
# 各工程の必要・提供機能を照合し、初回又は既存storeへのplan登録まで行う
|
|
38
38
|
show <plan_key> --json # task・依存辺・phase・状態をplan本体から1コマンドで投影する
|
|
39
|
+
scope-review --plan-input <file> --review <scope-review.json> --json
|
|
40
|
+
# 書き終えたplanの全taskが持ち主の作業仕様の内にあるかを、登録前に検査する
|
|
41
|
+
scope-review --schema --json # review入力のJSON Schemaを返す
|
|
39
42
|
compile --request <request.json>
|
|
40
43
|
compile --schema --json # lattice.run_request.v1 の JSON Schema を出す
|
|
41
44
|
verify --request <request.json> --plan <plan.json>
|
|
@@ -122,6 +125,8 @@ Write commands:
|
|
|
122
125
|
dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
123
126
|
dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
124
127
|
# 開発中に発見した依存を明示接続する。同一plan内の辺はplan本体を軽い改訂で書き換え(plan_versionが変わる)、plan跨ぎは台帳に積む。依存の自動推定は行わない
|
|
128
|
+
independence mode --plan <key> --set <witness|conversation> --reason <text>
|
|
129
|
+
# このplanの調整方式(witness検証で並列するか、会話で調整するか)を記録する
|
|
125
130
|
independence compile --plan <key> --input <file> # witness setとsensorから並列可否を記録する
|
|
126
131
|
independence witness migrate --plan <key> # revision後の宣言をtask migrationで写す
|
|
127
132
|
independence witness scaffold --plan <key> --input <draft> # 下書きとfresh観測から宣言を書き出す
|
|
@@ -274,7 +279,9 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
274
279
|
'todo note': 'todo note --plan <key> [--task <id>] (--message <text>|--input <file>) | list --plan <key> [--task <id>] --json',
|
|
275
280
|
'todo note list': 'todo note list --plan <key> [--task <id>] --json',
|
|
276
281
|
'todo bindings': 'todo bindings [--plan <key>] [--json]',
|
|
277
|
-
'todo independence': 'todo independence [--plan <key>] [--json] |
|
|
282
|
+
'todo independence': 'todo independence [--plan <key>] [--json] | mode --plan <key> --set <witness|conversation> --reason <text>'
|
|
283
|
+
+ ' | compile --plan <key> --input <file> | witness migrate --plan <key> | witness scaffold --plan <key> --input <draft>',
|
|
284
|
+
'todo independence mode': 'todo independence mode --plan <key> --set <witness|conversation> --reason <text>',
|
|
278
285
|
'todo structure': 'todo structure --schema --json | [--plan <key>] --json | input --plan <key> --input <file> [--dry-run --json] | compile --plan <key> --input <file> | realize --plan <key> --task <id> (--planned|--realized <actual-structure.json>) [--commit <HEAD|sha>]... | realize --plan <key> --task <id> --input <full-realization.json> | finalize --plan <key> --json',
|
|
279
286
|
'todo seam-profile': 'todo seam-profile --plan <key> --file <path> [--json]',
|
|
280
287
|
'todo seam-proposal': 'todo seam-proposal [--plan <key>] [--json] | compile --plan <key>',
|
|
@@ -49,6 +49,16 @@ const dependencyCycle = {
|
|
|
49
49
|
return `${edgeName(detail)} would close a cycle${path === null ? '' : ` (${path})`}: leave it out, or disconnect one edge of that path with \`lattice todo dependency disconnect\`.`;
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
|
+
// a23: dependency refusals name the edge or the task and a command that lists valid ones.
|
|
53
|
+
const depFlag = (ctx, name) => ctx.flags?.[name] ?? `<${name}>`;
|
|
54
|
+
const depRef = (detail) => (record(detail.ref) ? detail.ref : detail);
|
|
55
|
+
const missingSide = (ref, ctx) => (ctx.flags?.['to-plan'] === ref.plan_key
|
|
56
|
+
&& (ref.task_id === undefined || ctx.flags?.['to-task'] === ref.task_id) ? 'to' : 'from');
|
|
57
|
+
const dependencyExists = {
|
|
58
|
+
pointer: '--to-task',
|
|
59
|
+
repair: (detail) => `${edgeName(detail)} already exists, so there is nothing to add;`
|
|
60
|
+
+ ` see \`lattice plan show ${record(detail.to) ? detail.to.plan_key : '<plan>'} --json\`.`,
|
|
61
|
+
};
|
|
52
62
|
|
|
53
63
|
/** The flag that carried the unreadable input: the one whose value is the refused path. */
|
|
54
64
|
function inputFlag(detail, ctx) {
|
|
@@ -201,6 +211,22 @@ const REGISTRY = {
|
|
|
201
211
|
},
|
|
202
212
|
dependency_cycle: dependencyCycle,
|
|
203
213
|
cross_plan_dependency_cycle: dependencyCycle,
|
|
214
|
+
dependency_already_in_plan: dependencyExists,
|
|
215
|
+
cross_plan_dependency_duplicate: dependencyExists,
|
|
216
|
+
dependency_self_reference: {
|
|
217
|
+
pointer: '--to-task',
|
|
218
|
+
repair: (detail, ctx) => `--from-task and --to-task name the same task ${depFlag(ctx, 'to-plan')}/${depFlag(ctx, 'to-task')}; a task cannot depend on itself:`
|
|
219
|
+
+ ` set --from-task to the task it waits on (see \`lattice plan show ${depFlag(ctx, 'to-plan')} --json\`).`,
|
|
220
|
+
},
|
|
221
|
+
dependency_task_not_found: {
|
|
222
|
+
pointer: (detail, ctx) => `--${missingSide(depRef(detail), ctx)}-task`,
|
|
223
|
+
repair: (detail) => `No task ${q(depRef(detail).task_id ?? '')} in plan ${depRef(detail).plan_key}:`
|
|
224
|
+
+ ` run \`lattice plan show ${depRef(detail).plan_key} --json\` to list its task ids.`,
|
|
225
|
+
},
|
|
226
|
+
dependency_plan_not_found: {
|
|
227
|
+
pointer: (detail, ctx) => `--${missingSide(depRef(detail), ctx)}-plan`,
|
|
228
|
+
repair: (detail) => `${q(depRef(detail).plan_key ?? '')} is not an active plan: run \`lattice todo status --json\` to list the active plan keys.`,
|
|
229
|
+
},
|
|
204
230
|
join_self_edge: {
|
|
205
231
|
pointer: '/joins',
|
|
206
232
|
repair: () => 'Remove the join whose `after` lists its own id, then rerun.',
|
package/src/project-cli.mjs
CHANGED
|
@@ -317,14 +317,15 @@ async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts
|
|
|
317
317
|
// ready frontierが在る間はADR 0063の並列開始コマンドが勝つ
|
|
318
318
|
// ——ここを監査で上書きするとdispatchが再直列化する。監査待ちはtodo statusの
|
|
319
319
|
// audit_pending欄に常在するので、順位を下げても消えない。
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
// (`todo phase status`の結果には既に両分岐のguidanceが載っている)。
|
|
320
|
+
// gate_ready(全taskが終わり監査も未着手)は軽い出口close-unauditedを1行で示す(a22)。
|
|
321
|
+
// 監査を始めた後(reviewing/rejected)は読み取り専用の`todo phase status`が両分岐を示す。
|
|
323
322
|
: todo.structure_finalization_pending.length > 0
|
|
324
323
|
? { command: todo.structure_finalization_pending[0].next_commands[0],
|
|
325
324
|
reason: 'structure_finalization_pending' }
|
|
326
325
|
: todo.audit_pending.length > 0
|
|
327
|
-
? { command:
|
|
326
|
+
? { command: todo.audit_pending[0].phase_status === 'gate_ready'
|
|
327
|
+
? `lattice todo phase close-unaudited --plan ${todo.audit_pending[0].plan_key} --phase ${todo.audit_pending[0].phase_id} --reason <text>`
|
|
328
|
+
: `lattice todo phase status --plan ${todo.audit_pending[0].plan_key}`,
|
|
328
329
|
reason: 'audit_pending' }
|
|
329
330
|
: { command: 'lattice todo status', reason: 'no_ready_task' };
|
|
330
331
|
const result = statusResult({
|
package/src/setup-cli.mjs
CHANGED
|
@@ -24,7 +24,9 @@ async function hookResult(host, options, statusOnly) {
|
|
|
24
24
|
if (installed.exit !== 0) return { ...installed.result, state: 'failed' };
|
|
25
25
|
}
|
|
26
26
|
const status = await invoke('status');
|
|
27
|
-
|
|
27
|
+
if (status.exit === 0 && status.result.state === 'wired') return { ...status.result, state: 'verified' };
|
|
28
|
+
// Keep setup's verified/failed, and name the hooks status state as the code (as MCP does).
|
|
29
|
+
return { ...status.result, state: 'failed', code: `HOOKS_${String(status.result.state ?? 'failed').toUpperCase()}` };
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
async function configureHost(host, options, statusOnly) {
|
|
@@ -307,7 +307,13 @@ function looksLikeProse(value) {
|
|
|
307
307
|
|| (/\s/u.test(value) && !/[/\\]/u.test(value));
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
function outsideRepoAction(canonicalRoot, inlineFlag) {
|
|
311
|
+
return 'この引数は証拠としてrepo内のpathとgit blobで記録し、他の席がそれを検証するので、repo内のfileだけ受理する。'
|
|
312
|
+
+ `repo外(/tmp等)にあるならrepo内へ写してから渡す${inlineFlag ? `か、本文を ${inlineFlag} <text> で渡す` : ''}(repo_root: ${canonicalRoot})`;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// allowOutsideRepo: 中身だけを読むcaller(JSON入力・note本文・test result)はrepo外の絶対pathも受ける(a17, a23)。
|
|
316
|
+
// 証拠はrepo内のpathとgit blobで記録し他の席が検証するので、既定のまま拒む。
|
|
311
317
|
export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
312
318
|
inlineFlag = null, allowOutsideRepo = false,
|
|
313
319
|
} = {}) {
|
|
@@ -318,6 +324,8 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
|
318
324
|
const candidate = path.isAbsolute(inputRef)
|
|
319
325
|
? inputRef
|
|
320
326
|
: path.resolve(canonicalRoot, inputRef);
|
|
327
|
+
// a23: 「repo内」と言うのは、repo外を拒むcallerの時だけ。
|
|
328
|
+
const fileKind = allowOutsideRepo ? 'file path(repo外は絶対path)' : 'repo内のfile path';
|
|
321
329
|
let stats;
|
|
322
330
|
try { stats = await lstat(candidate); } catch {
|
|
323
331
|
fail('INPUT_UNREADABLE', 'input_missing', {
|
|
@@ -325,9 +333,9 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
|
325
333
|
repo_root: canonicalRoot,
|
|
326
334
|
next_action: looksLikeProse(inputRef)
|
|
327
335
|
? (inlineFlag
|
|
328
|
-
?
|
|
329
|
-
:
|
|
330
|
-
:
|
|
336
|
+
? `この引数は${fileKind}を取る。文章をそのまま渡すなら ${inlineFlag} <text> を使う`
|
|
337
|
+
: `この引数は${fileKind}を取る。渡された値は本文に見える——先にfileへ書いてからそのpathを渡す`)
|
|
338
|
+
: `存在する${fileKind}を渡す(相対pathはrepo_rootから解く: ${canonicalRoot})`,
|
|
331
339
|
});
|
|
332
340
|
}
|
|
333
341
|
if (stats.isSymbolicLink() || !stats.isFile()) {
|
|
@@ -342,7 +350,7 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
|
342
350
|
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
343
351
|
input_ref: inputRef,
|
|
344
352
|
repo_root: canonicalRoot,
|
|
345
|
-
next_action:
|
|
353
|
+
next_action: outsideRepoAction(canonicalRoot, inlineFlag),
|
|
346
354
|
});
|
|
347
355
|
}
|
|
348
356
|
if (stats.size > MAX_AUTHORING_INPUT_BYTES) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
@@ -351,7 +359,7 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
|
351
359
|
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
352
360
|
input_ref: inputRef,
|
|
353
361
|
repo_root: canonicalRoot,
|
|
354
|
-
next_action:
|
|
362
|
+
next_action: outsideRepoAction(canonicalRoot, inlineFlag),
|
|
355
363
|
});
|
|
356
364
|
}
|
|
357
365
|
return {
|
package/src/todo-cli.mjs
CHANGED
|
@@ -293,6 +293,8 @@ const DONE_FLAG_SPEC = Object.freeze({
|
|
|
293
293
|
});
|
|
294
294
|
|
|
295
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'] });
|
|
296
298
|
const DEPENDENCY_FLAG_SPEC = Object.freeze({
|
|
297
299
|
known: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
298
300
|
required: ['from-plan', 'from-task', 'to-plan', 'to-task', 'reason'],
|
|
@@ -312,10 +314,15 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
312
314
|
reopen: Object.freeze({ known: ['plan', 'task', 'reason', 'override-reason'], required: ['plan', 'task', 'reason'] }),
|
|
313
315
|
'dependency connect': DEPENDENCY_FLAG_SPEC,
|
|
314
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,
|
|
315
322
|
});
|
|
316
|
-
const IDENTIFIER_FLAGS = ['plan', 'task', 'from-plan', 'from-task', 'to-plan', 'to-task'];
|
|
323
|
+
const IDENTIFIER_FLAGS = ['plan', 'task', 'phase', 'from-plan', 'from-task', 'to-plan', 'to-task'];
|
|
317
324
|
const FLAG_PLACEHOLDER = { reason: '<text>', 'override-reason': '<text>', message: '<text>',
|
|
318
|
-
evidence: '<file>', 'test-result': '<file>' };
|
|
325
|
+
evidence: '<file>', 'test-result': '<file>', input: '<file>' };
|
|
319
326
|
const shellWord = (value) => (/^[\w./:@-]+$/u.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`);
|
|
320
327
|
|
|
321
328
|
/** The command again, with the flags given and a placeholder for each missing required flag. */
|
|
@@ -332,12 +339,19 @@ function repairedCommand(head, spec, flags) {
|
|
|
332
339
|
/** `dependency connect|disconnect` flags by name (order-free), or null. */
|
|
333
340
|
function dependencyFlags(argv) {
|
|
334
341
|
const flags = matchFlagCommand(argv, argv.slice(0, 2), DEPENDENCY_FLAG_SPEC);
|
|
335
|
-
return flags !== null && IDENTIFIER_FLAGS.slice(
|
|
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;
|
|
336
349
|
}
|
|
337
350
|
|
|
338
351
|
/** A todo write's argument refusal names the flag, the rule and the command to run instead. */
|
|
339
352
|
function explainArgumentRefusal(argv) {
|
|
340
|
-
|
|
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);
|
|
341
355
|
const spec = TODO_FLAG_SPECS[head.join(' ')];
|
|
342
356
|
if (spec === undefined) return {};
|
|
343
357
|
const { flags } = parseFlagMap(argv.slice(head.length));
|
|
@@ -347,8 +361,27 @@ function explainArgumentRefusal(argv) {
|
|
|
347
361
|
}
|
|
348
362
|
if (flagFailure !== null) return flagFailure;
|
|
349
363
|
for (const name of IDENTIFIER_FLAGS.filter((key) => spec.known.includes(key))) {
|
|
364
|
+
if (flags[name] === undefined && !spec.required.includes(name)) continue;
|
|
350
365
|
if (!isTodoIdentifier(flags[name])) return { pointer: `--${name}`, rule: 'identifier_invalid', actual: flags[name] };
|
|
351
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
|
+
}
|
|
352
385
|
for (const name of ['override-reason', 'reason']) {
|
|
353
386
|
if (spec.known.includes(name) && flags[name] !== undefined
|
|
354
387
|
&& !(typeof flags[name] === 'string' && flags[name].length > 0)) {
|
|
@@ -434,7 +467,8 @@ function selectNoteTask(member, requestedTaskId) {
|
|
|
434
467
|
}
|
|
435
468
|
|
|
436
469
|
async function readNoteTextInput(repoRoot, inputRef) {
|
|
437
|
-
|
|
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 });
|
|
438
472
|
const bytes = await readFile(located.absolute);
|
|
439
473
|
if (bytes.length > MAX_NOTE_INPUT_BYTES) {
|
|
440
474
|
throw new TodoStoreError('INPUT_TOO_LARGE', 'note_input_too_large');
|
|
@@ -567,23 +601,30 @@ function looksLikeEvidenceDescriptor(value) {
|
|
|
567
601
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
568
602
|
}
|
|
569
603
|
|
|
570
|
-
function writeEvidenceBlob(repoRoot, bytes, blobPath) {
|
|
604
|
+
function writeEvidenceBlob(repoRoot, bytes, blobPath, write = true) {
|
|
571
605
|
// worktree pathから作る証拠は`git add`と同じclean filterを通す。生のCRLF bytesを
|
|
572
606
|
// そのままhashすると、commit先はLFへ正規化される一方、descriptorはdangling blobを
|
|
573
607
|
// 指すため、commit後もhard検証を通せない。
|
|
574
|
-
const oid = gitSync(['hash-object', '-w', `--path=${blobPath}`, '--stdin'], {
|
|
608
|
+
const oid = gitSync(['hash-object', ...(write ? ['-w'] : []), `--path=${blobPath}`, '--stdin'], {
|
|
575
609
|
cwd: repoRoot, input: bytes, encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'],
|
|
576
610
|
}).trim();
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
+
}
|
|
580
619
|
return {
|
|
581
620
|
git_blob_oid: oid,
|
|
582
621
|
content_digest: createHash('sha256').update(storedBytes).digest('hex'),
|
|
583
622
|
};
|
|
584
623
|
}
|
|
585
624
|
|
|
586
|
-
async function resolveDoneEvidence({
|
|
625
|
+
async function resolveDoneEvidence({
|
|
626
|
+
repoRoot, evidenceRef, evidenceMessage, planKey, taskId, write = true, inlineFlag = null,
|
|
627
|
+
}) {
|
|
587
628
|
if (typeof evidenceMessage === 'string') {
|
|
588
629
|
const bytes = Buffer.from(evidenceMessage, 'utf8');
|
|
589
630
|
const sourceDigest = createHash('sha256').update(bytes).digest('hex');
|
|
@@ -592,16 +633,16 @@ async function resolveDoneEvidence({ repoRoot, evidenceRef, evidenceMessage, pla
|
|
|
592
633
|
evidence_id: evidenceIdFor(planKey, taskId),
|
|
593
634
|
repo_id: 'self',
|
|
594
635
|
path: evidencePath,
|
|
595
|
-
...writeEvidenceBlob(repoRoot, bytes, evidencePath),
|
|
636
|
+
...writeEvidenceBlob(repoRoot, bytes, evidencePath, write),
|
|
596
637
|
media_type: 'text/markdown',
|
|
597
638
|
anchor_digest: null,
|
|
598
639
|
};
|
|
599
|
-
if (!validateEvidenceDescriptor(descriptor) || !isTodoRef(descriptor.path)) {
|
|
640
|
+
if (write && (!validateEvidenceDescriptor(descriptor) || !isTodoRef(descriptor.path))) {
|
|
600
641
|
throw new TodoStoreError('INVALID_EVIDENCE', 'authored_evidence_descriptor_invalid');
|
|
601
642
|
}
|
|
602
643
|
return descriptor;
|
|
603
644
|
}
|
|
604
|
-
const located = await resolveAuthoringInputPath(repoRoot, evidenceRef, { inlineFlag
|
|
645
|
+
const located = await resolveAuthoringInputPath(repoRoot, evidenceRef, { inlineFlag });
|
|
605
646
|
const bytes = await readFile(located.absolute);
|
|
606
647
|
let text;
|
|
607
648
|
try { text = new TextDecoder('utf-8', { fatal: true }).decode(bytes); }
|
|
@@ -624,11 +665,11 @@ async function resolveDoneEvidence({ repoRoot, evidenceRef, evidenceMessage, pla
|
|
|
624
665
|
evidence_id: evidenceIdFor(planKey, taskId),
|
|
625
666
|
repo_id: 'self',
|
|
626
667
|
path: located.inputRef,
|
|
627
|
-
...writeEvidenceBlob(repoRoot, bytes, located.inputRef),
|
|
668
|
+
...writeEvidenceBlob(repoRoot, bytes, located.inputRef, write),
|
|
628
669
|
media_type: mediaTypeFor(located.inputRef),
|
|
629
670
|
anchor_digest: null,
|
|
630
671
|
};
|
|
631
|
-
if (!validateEvidenceDescriptor(descriptor)) {
|
|
672
|
+
if (write && !validateEvidenceDescriptor(descriptor)) {
|
|
632
673
|
throw new TodoStoreError('INVALID_EVIDENCE', 'authored_evidence_descriptor_invalid');
|
|
633
674
|
}
|
|
634
675
|
return descriptor;
|
|
@@ -686,23 +727,13 @@ async function readStructureSetDraft(repoRoot, inputRef) {
|
|
|
686
727
|
}
|
|
687
728
|
|
|
688
729
|
/**
|
|
689
|
-
* gate_ready
|
|
690
|
-
*
|
|
691
|
-
* 0.36.0で入れた終端監査gate(ADR 0147)は、これから終わる工程だけでなく過去に完了した
|
|
692
|
-
* 工程まで監査待ちにしてしまっていた——原因を言わないgateは、なぜ止まっているかを
|
|
693
|
-
* 説明しないのと同じなので、ここでその経緯を明示する。次の一歩は2択で書く:
|
|
694
|
-
* 今から監査する(review→accept)か、監査せず歴史として閉じる(close-unaudited、
|
|
695
|
-
* 複数plan一括ならbaseline)か。
|
|
730
|
+
* gate_readyの次の一歩を1行で言う(ADR 0148裁定8・a22)。全taskが終わった席には、軽い出口
|
|
731
|
+
* (監査せず閉じるclose-unaudited)を先に、監査する道(review→accept)を後に示す。経緯の説明は載せない。
|
|
696
732
|
*/
|
|
697
733
|
function auditGateGuidance(planKey, phaseId) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
+
|
|
701
|
-
+ `todo phase review --plan ${planKey} --phase ${phaseId} --reason <text> → `
|
|
702
|
-
+ `todo phase accept --plan ${planKey} --phase ${phaseId} --input <file>。`
|
|
703
|
-
+ '監査せず歴史として閉じるなら: '
|
|
704
|
-
+ `todo phase close-unaudited --plan ${planKey} --phase ${phaseId} --reason <text>`
|
|
705
|
-
+ '(複数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>)`;
|
|
706
737
|
}
|
|
707
738
|
|
|
708
739
|
/**
|
|
@@ -766,6 +797,8 @@ async function mutate({
|
|
|
766
797
|
? null
|
|
767
798
|
: await resolveDoneEvidence({
|
|
768
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,
|
|
769
802
|
});
|
|
770
803
|
const testResult = testResultRef === null ? null : await readTestResultInput(repoRoot, testResultRef);
|
|
771
804
|
const materializedEvidence = typeof evidenceMessage === 'string'
|
|
@@ -851,8 +884,21 @@ const UNCHANGED_WHEN = {
|
|
|
851
884
|
retire: ({ status }) => status === 'retired',
|
|
852
885
|
};
|
|
853
886
|
|
|
854
|
-
|
|
855
|
-
|
|
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 () => [] }) {
|
|
856
902
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
857
903
|
const matches = member?.tasks.filter(({ task_id: current }) => current.toLowerCase() === taskId.toLowerCase()) ?? [];
|
|
858
904
|
// Unknown or ambiguous plan/task: the append path keeps Store's refusal.
|
|
@@ -863,18 +909,17 @@ function unchangedTransition(store, { env, planKey, taskId, kind, notRecorded =
|
|
|
863
909
|
// Another seat's in-progress task is not this seat's repeated start; keep the task_state refusal.
|
|
864
910
|
if (kind === 'start' && recorded?.actor?.agent !== resolveTodoActor(env).agent) return null;
|
|
865
911
|
const shown = recorded ?? events.findLast((event) => event.task_id === state.task_id) ?? events.at(-1);
|
|
912
|
+
const notRecorded = await dropped(recorded);
|
|
866
913
|
const result = {
|
|
867
914
|
schema: 'lattice.todo_mutation_result.v2',
|
|
868
915
|
project_id: member.plan.project_id, plan_key: planKey, plan_version: member.plan.plan_version,
|
|
869
916
|
task_id: state.task_id, kind, sequence: shown.sequence, event_digest: shown.event_digest,
|
|
870
917
|
journal_head_digest: events.at(-1).event_digest, snapshot_digest: member.snapshot.snapshot_digest,
|
|
871
918
|
status: state.status, advisory: null, unchanged: true,
|
|
872
|
-
// a18: a repeated
|
|
919
|
+
// a18: a repeated transition appends nothing, so say which given content was not recorded.
|
|
873
920
|
...(notRecorded.length === 0 ? {} : {
|
|
874
921
|
not_recorded: notRecorded,
|
|
875
|
-
next_action: `${planKey}/${state.task_id}
|
|
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.`,
|
|
922
|
+
next_action: `${planKey}/${state.task_id} ${NOT_RECORDED_NEXT[kind](`--plan ${planKey} --task ${state.task_id}`, notRecorded.join(', '))}`,
|
|
878
923
|
}),
|
|
879
924
|
result_digest: '',
|
|
880
925
|
};
|
|
@@ -885,7 +930,46 @@ function unchangedTransition(store, { env, planKey, taskId, kind, notRecorded =
|
|
|
885
930
|
/** block/unblock/done: an unchanged no-op first, else the append path. */
|
|
886
931
|
async function mutateUnlessUnchanged(options) {
|
|
887
932
|
const store = await readTodoStore({ repoRoot: options.repoRoot });
|
|
888
|
-
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
|
+
];
|
|
889
973
|
}
|
|
890
974
|
|
|
891
975
|
/** a18: the live tasks with an edge (plan, join or ledger) from the task being retired, sorted. */
|
|
@@ -916,7 +1000,9 @@ async function retireTask({ repoRoot, env, planKey, taskId, reason }) {
|
|
|
916
1000
|
// 未知のplan/taskはStoreの既存の拒否をそのまま通す。
|
|
917
1001
|
return mutate({ repoRoot, env, planKey, taskId, kind: 'retire', payload: { reason }, evidenceRef: null });
|
|
918
1002
|
}
|
|
919
|
-
if (state.status === 'retired')
|
|
1003
|
+
if (state.status === 'retired') {
|
|
1004
|
+
return unchangedTransition(store, { env, planKey, taskId, kind: 'retire', dropped: reasonDropped(reason) });
|
|
1005
|
+
}
|
|
920
1006
|
const dependents = retireDependents(store, member, taskId);
|
|
921
1007
|
const append = async () => {
|
|
922
1008
|
let result;
|
|
@@ -1116,7 +1202,7 @@ async function startTask({
|
|
|
1116
1202
|
});
|
|
1117
1203
|
}
|
|
1118
1204
|
const resolvedTaskId = readyTask?.task_id ?? taskMatches[0].task_id;
|
|
1119
|
-
const unchanged = unchangedTransition(store, { env, planKey, taskId: resolvedTaskId, kind: 'start' });
|
|
1205
|
+
const unchanged = await unchangedTransition(store, { env, planKey, taskId: resolvedTaskId, kind: 'start' });
|
|
1120
1206
|
if (unchanged !== null) return unchanged;
|
|
1121
1207
|
// noteはjournal appendより前に読む。壊れていてもstartは通す(ADR 0166 / 0181)。
|
|
1122
1208
|
let noteContext;
|
|
@@ -4179,9 +4265,9 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4179
4265
|
meaning: 'source_inventory_verification_state',
|
|
4180
4266
|
lifecycle_blocked: false,
|
|
4181
4267
|
dashboard_visibility_blocked: false,
|
|
4182
|
-
//
|
|
4183
|
-
schema_command:
|
|
4184
|
-
next_action: reconciled ? null : '
|
|
4268
|
+
// registered_unreconciledは何もしなくてよい状態(a22)。次の軽い改訂がreconciledにする。
|
|
4269
|
+
schema_command: null,
|
|
4270
|
+
next_action: reconciled ? null : 'none',
|
|
4185
4271
|
},
|
|
4186
4272
|
};
|
|
4187
4273
|
});
|
|
@@ -4216,7 +4302,7 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4216
4302
|
// ここへ届くのは検証が通った結果だけ。注意が要るのはsnapshot古さとcommit前の証拠)。
|
|
4217
4303
|
function verifyVerdictLine(result) {
|
|
4218
4304
|
const members = result.verified_members.map((member) => `${member.plan_key} ${member.reconciliation_state}${
|
|
4219
|
-
member.reconciliation_state === 'reconciled' ? '' : ',
|
|
4305
|
+
member.reconciliation_state === 'reconciled' ? '' : ', nothing to do'}`);
|
|
4220
4306
|
const notes = [];
|
|
4221
4307
|
if (result.snapshot_stale) notes.push('snapshot stale');
|
|
4222
4308
|
if (result.uncommitted_evidence.length > 0) {
|
|
@@ -4357,10 +4443,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4357
4443
|
&& (argv.length === 3 || argv[3] === '--json')) {
|
|
4358
4444
|
action = (repoRoot) => bindings({ repoRoot, requestedPlanKey: argv[2] });
|
|
4359
4445
|
} else if (argv[0] === 'note' && argv[1] !== 'list') {
|
|
4360
|
-
const flags = matchFlagCommand(argv, ['note'],
|
|
4361
|
-
known: ['plan', 'task', 'message', 'input', 'supersedes'],
|
|
4362
|
-
required: ['plan'],
|
|
4363
|
-
});
|
|
4446
|
+
const flags = matchFlagCommand(argv, ['note'], NOTE_FLAG_SPEC);
|
|
4364
4447
|
const hasMessage = typeof flags?.message === 'string' && flags.message.length > 0;
|
|
4365
4448
|
const hasInput = isAuthoringPathToken(flags?.input);
|
|
4366
4449
|
if (flags !== null && isTodoIdentifier(flags.plan)
|
|
@@ -4544,9 +4627,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4544
4627
|
action = (repoRoot) => revise({ repoRoot, env, planKey: flags.plan, inputRef: flags.input });
|
|
4545
4628
|
}
|
|
4546
4629
|
} else if (argv[0] === 'split') {
|
|
4547
|
-
const flags = matchFlagCommand(argv, ['split'],
|
|
4548
|
-
known: ['plan', 'input'], required: ['plan', 'input'],
|
|
4549
|
-
});
|
|
4630
|
+
const flags = matchFlagCommand(argv, ['split'], TODO_FLAG_SPECS.split);
|
|
4550
4631
|
if (flags !== null && isTodoIdentifier(flags.plan) && isAuthoringPathToken(flags.input)) {
|
|
4551
4632
|
action = (repoRoot) => splitTodo({ repoRoot, env, planKey: flags.plan, inputRef: flags.input });
|
|
4552
4633
|
}
|
|
@@ -4567,12 +4648,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4567
4648
|
} else if (argv.length === 4 && argv[0] === 'phase' && argv[1] === 'status'
|
|
4568
4649
|
&& argv[2] === '--plan' && isTodoIdentifier(argv[3])) {
|
|
4569
4650
|
action = (repoRoot) => phaseStatus({ repoRoot, planKey: argv[3] });
|
|
4570
|
-
} else if (argv
|
|
4571
|
-
&& argv
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
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 } });
|
|
4576
4656
|
} else if (argv[0] === 'phase' && ['accept', 'reject'].includes(argv[1])) {
|
|
4577
4657
|
const outcome = argv[1];
|
|
4578
4658
|
const flags = matchFlagCommand(argv, ['phase', outcome], {
|
|
@@ -4599,12 +4679,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4599
4679
|
&& (argv.length === 8 || (argv[8] === '--override-reason' && argv[9].length > 0))) {
|
|
4600
4680
|
action = (repoRoot) => phaseMutation({ repoRoot, env, planKey: argv[3], phaseId: argv[5],
|
|
4601
4681
|
kind: 'phase_reopen', payload: { reason: argv[7], override_reason: argv[9] ?? null } });
|
|
4602
|
-
} else if (argv
|
|
4603
|
-
&& argv
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
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 } });
|
|
4608
4687
|
} else if (argv.length >= 4 && argv[0] === 'phase' && argv[1] === 'baseline'
|
|
4609
4688
|
&& argv[2] === '--reason' && argv[3].length > 0
|
|
4610
4689
|
&& parseBaselineExceptFlags(argv.slice(4)) !== null) {
|
|
@@ -4629,36 +4708,17 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4629
4708
|
}
|
|
4630
4709
|
} else if (argv[0] === 'done') {
|
|
4631
4710
|
const flags = matchFlagCommand(argv, ['done'], DONE_FLAG_SPEC);
|
|
4632
|
-
const hasEvidence = isAuthoringPathToken(flags?.evidence);
|
|
4633
|
-
const hasMessage = typeof flags?.message === 'string' && flags.message.length > 0;
|
|
4634
4711
|
// u03 A58: both, one or neither of --evidence/--message is accepted.
|
|
4635
4712
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)
|
|
4636
|
-
&& (flags.evidence === undefined ||
|
|
4713
|
+
&& (flags.evidence === undefined || isAuthoringPathToken(flags.evidence))
|
|
4637
4714
|
&& (flags['test-result'] === undefined || isAuthoringPathToken(flags['test-result']))) {
|
|
4638
4715
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4639
|
-
kind: 'done',
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
const file = await resolveDoneEvidence({
|
|
4646
|
-
repoRoot, evidenceRef: flags.evidence, evidenceMessage: null,
|
|
4647
|
-
planKey: flags.plan, taskId: flags.task,
|
|
4648
|
-
});
|
|
4649
|
-
evidenceMessage = `${flags.message}\n\nevidence: ${file.repo_id}:${file.path}`
|
|
4650
|
-
+ ` (git blob ${file.git_blob_oid}, sha256 ${file.content_digest})\n`;
|
|
4651
|
-
} else if (!hasEvidence && !hasMessage) {
|
|
4652
|
-
evidenceMessage = DONE_WITHOUT_EVIDENCE_MESSAGE;
|
|
4653
|
-
}
|
|
4654
|
-
return mutate({
|
|
4655
|
-
repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4656
|
-
kind: 'done', payload: 'authored',
|
|
4657
|
-
evidenceRef: evidenceMessage === null ? flags.evidence : null,
|
|
4658
|
-
evidenceMessage,
|
|
4659
|
-
testResultRef: flags['test-result'] ?? null,
|
|
4660
|
-
});
|
|
4661
|
-
} });
|
|
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
|
+
}) });
|
|
4662
4722
|
}
|
|
4663
4723
|
}
|
|
4664
4724
|
if (action === null && argv[0] === 'retract') {
|
|
@@ -4672,7 +4732,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4672
4732
|
const flags = matchFlagCommand(argv, ['block'], TODO_FLAG_SPECS.block);
|
|
4673
4733
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4674
4734
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4675
|
-
kind: 'block', action: () => mutate({
|
|
4735
|
+
kind: 'block', dropped: reasonDropped(flags.reason), action: () => mutate({
|
|
4676
4736
|
repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4677
4737
|
kind: 'block', payload: { reason: flags.reason }, evidenceRef: null,
|
|
4678
4738
|
}) });
|