@quolu/lattice 0.86.1 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +4 -3
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +4 -3
- package/package.json +1 -1
- package/src/cli-help.mjs +9 -5
- package/src/project-cli.mjs +8 -5
- package/src/todo-audit-pending.mjs +9 -2
- package/src/todo-authoring-input.mjs +3 -6
- package/src/todo-cli.mjs +148 -15
- package/src/todo-contracts.mjs +2 -1
- package/src/todo-independence-guidance.mjs +4 -2
- package/src/todo-status.mjs +3 -1
|
@@ -2,8 +2,8 @@
|
|
|
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 carries a design memo; an omitted, null or blank one is
|
|
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
|
|
5
|
+
"description": "Canonical initial authoring input for a phase-audited plan. Every task carries a design memo; an omitted, null or blank one is refused at its pointer (write `NO_PLAN` yourself when you have 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. actor, recorded_at and input_digest may be omitted: the machine fills the seat actor and the current time, recomputes input_digest and sorts every list into canonical order.",
|
|
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 is refused; NO_PLAN only when written), 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,
|
|
9
9
|
"required": [
|
|
@@ -151,7 +151,8 @@
|
|
|
151
151
|
"narrative_anchor",
|
|
152
152
|
"compile_binding",
|
|
153
153
|
"parent_task_id",
|
|
154
|
-
"phase_id"
|
|
154
|
+
"phase_id",
|
|
155
|
+
"design_memo"
|
|
155
156
|
],
|
|
156
157
|
"properties": {
|
|
157
158
|
"task_id": {
|
|
@@ -2,8 +2,8 @@
|
|
|
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 carries a design memo; an omitted, null or blank one is
|
|
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
|
|
5
|
+
"description": "Canonical initial authoring input for a phase-audited plan. Every task carries a design memo; an omitted, null or blank one is refused at its pointer (write `NO_PLAN` yourself when you have 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. 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[].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
|
+
"$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 is refused; NO_PLAN only when written), 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,
|
|
9
9
|
"required": [
|
|
@@ -139,7 +139,8 @@
|
|
|
139
139
|
"required": [
|
|
140
140
|
"task_id",
|
|
141
141
|
"title",
|
|
142
|
-
"phase_id"
|
|
142
|
+
"phase_id",
|
|
143
|
+
"design_memo"
|
|
143
144
|
],
|
|
144
145
|
"properties": {
|
|
145
146
|
"task_id": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
package/src/cli-help.mjs
CHANGED
|
@@ -29,7 +29,7 @@ Commands:
|
|
|
29
29
|
# 結果へdispatch_shapeを載せる。--serialization-reviewedは互換のため受理するだけで門ではない
|
|
30
30
|
create --schema --json # 既定は最新版(v5)のJSON Schemaを返す
|
|
31
31
|
create --schema-version <1|2|3|4|5> --json
|
|
32
|
-
create --template --json # 作者が書くkeyだけの最小のv5
|
|
32
|
+
create --template --json # 作者が書くkeyだけの最小のv5入力(各taskの設計メモを書けばplan createが受理する)
|
|
33
33
|
backchain --schema --json # 最終成果から必要な機能を逆算する入力契約
|
|
34
34
|
revise [--plan <key>] --input <file> [--dry-run] [--json]
|
|
35
35
|
# --planは任意。入力にplan_keyが無ければ補い、違えばplan_revise_plan_key_mismatchで断る
|
|
@@ -137,7 +137,8 @@ Write commands:
|
|
|
137
137
|
dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
138
138
|
dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>
|
|
139
139
|
# 開発中に発見した依存を明示接続する。同一plan内の辺はplan本体を軽い改訂で書き換え(plan_versionが変わる)、plan跨ぎは台帳に積む。依存の自動推定は行わない
|
|
140
|
-
independence mode --plan <key> --set <witness|conversation> --reason <text>
|
|
140
|
+
independence mode --plan <key> --set <witness|conversation|enforced> --reason <text>
|
|
141
|
+
# enforced = witness+未宣言・古い宣言・衝突・参照なしdone・heavy段階の監査なし閉じを止める(ADR 0200)
|
|
141
142
|
# このplanの調整方式(witness検証で並列するか、会話で調整するか)を記録する
|
|
142
143
|
independence compile --plan <key> --input <file> # witness setとsensorから並列可否を記録する
|
|
143
144
|
independence compile --schema --json # compileが読むwitness set(lattice.todo_witness_set.v5)のJSON Schema
|
|
@@ -145,6 +146,8 @@ Write commands:
|
|
|
145
146
|
independence witness scaffold --template --plan <key> [--json] # 未完の工程を並べた下書きのひな形を出す
|
|
146
147
|
independence witness scaffold --schema --json # 下書き(lattice.todo_witness_draft.v2)のJSON Schema
|
|
147
148
|
independence witness scaffold --plan <key> --input <draft> # 下書きとfresh観測から宣言を書き出す
|
|
149
|
+
independence witness declare --plan <key> --task <id> [--owns <path>[,<path>...]] [--reads ...] [--writes ...]
|
|
150
|
+
# 1件のtaskの行だけを宣言する(a40)。readyが全部宣言済みならcompileまで行い、未宣言はwaiting_forに返す
|
|
148
151
|
structure input --plan <key> --input <file> --dry-run --json
|
|
149
152
|
# plan identity・topology・unfinished task coverage・baseline祖先を無変更で検査する
|
|
150
153
|
structure input --plan <key> --input <file>
|
|
@@ -300,10 +303,11 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
300
303
|
'todo display': 'todo display read [--json] | source [--json] # host表示用の読取。不整合でも断らずstateで返す',
|
|
301
304
|
'todo display read': 'todo display read [--json] # lattice.todo_display_read_result.v1(state: verified|unverified|last_verified|unavailable)',
|
|
302
305
|
'todo display source': 'todo display source [--json] # lattice.todo_store_display_source.v1(安い変更検知。変わった時だけreadする)',
|
|
303
|
-
'todo independence': 'todo independence [--plan <key>] [--json] | mode --plan <key> --set <witness|conversation> --reason <text>'
|
|
306
|
+
'todo independence': 'todo independence [--plan <key>] [--json] | mode --plan <key> --set <witness|conversation|enforced> --reason <text>'
|
|
304
307
|
+ ' | compile --plan <key> --input <file> | compile --schema --json | witness migrate --plan <key>'
|
|
305
|
-
+ ' | witness scaffold --template --plan <key> [--json] | witness scaffold --schema --json | witness scaffold --plan <key> --input <draft>'
|
|
306
|
-
|
|
308
|
+
+ ' | witness scaffold --template --plan <key> [--json] | witness scaffold --schema --json | witness scaffold --plan <key> --input <draft>'
|
|
309
|
+
+ ' | witness declare --plan <key> --task <id> [--owns <path>[,<path>...]] [--reads ...] [--writes ...]',
|
|
310
|
+
'todo independence mode': 'todo independence mode --plan <key> --set <witness|conversation|enforced> --reason <text>',
|
|
307
311
|
'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',
|
|
308
312
|
'todo seam-profile': 'todo seam-profile --plan <key> --file <path> [--json]',
|
|
309
313
|
'todo seam-proposal': 'todo seam-proposal [--plan <key>] [--json] | compile --plan <key>',
|
package/src/project-cli.mjs
CHANGED
|
@@ -325,7 +325,8 @@ async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts
|
|
|
325
325
|
reason: 'structure_finalization_pending' }
|
|
326
326
|
: todo.audit_pending.length > 0
|
|
327
327
|
? { command: todo.audit_pending[0].phase_status === 'gate_ready'
|
|
328
|
-
|
|
328
|
+
// close-unaudited when offered; an enforced heavy phase offers only review (ADR 0200).
|
|
329
|
+
? todo.audit_pending[0].next_commands.at(-1)
|
|
329
330
|
: `lattice todo phase status --plan ${todo.audit_pending[0].plan_key}`,
|
|
330
331
|
reason: 'audit_pending' }
|
|
331
332
|
: { command: 'lattice todo status', reason: 'no_ready_task' };
|
|
@@ -922,7 +923,8 @@ export async function runPlanCreateSchema({ stdout, version = 5 }) {
|
|
|
922
923
|
* `plan create --template --json`(a11・a17)。作者が書くkeyだけの最小のv5入力を出す。
|
|
923
924
|
* 機械が決めるkey(project_id・plan_version・actor・recorded_at・input_digest・定数のkey・辺のproject_id/plan_key)は載せない。
|
|
924
925
|
* plan_keyだけは、git repo内ならrepo root名から導いた値、repo外なら'main'。
|
|
925
|
-
* 決定的で、storeを読まない。id
|
|
926
|
+
* 決定的で、storeを読まない。id・題名を書き換え、各taskの設計メモを書けば`plan create`が受理する。
|
|
927
|
+
* 設計メモは空のまま出す: Latticeは自分でNO_PLANを書かず、写しただけの入力は欄名と促しで断られる。
|
|
926
928
|
*/
|
|
927
929
|
export const PLAN_CREATE_TEMPLATE = Object.freeze({
|
|
928
930
|
schema: DONE_CONDITION_CREATE_INPUT_SCHEMA,
|
|
@@ -932,9 +934,10 @@ export const PLAN_CREATE_TEMPLATE = Object.freeze({
|
|
|
932
934
|
{ phase_id: 'p2', title: 'Second phase' },
|
|
933
935
|
],
|
|
934
936
|
tasks: [
|
|
935
|
-
|
|
936
|
-
{ task_id: '
|
|
937
|
-
{ task_id: '
|
|
937
|
+
// The author writes each memo (or NO_PLAN); Lattice never writes one (memo-no-fabrication).
|
|
938
|
+
{ task_id: 't1', title: 'First task', phase_id: 'p1', design_memo: '' },
|
|
939
|
+
{ task_id: 't2', title: 'Second task', phase_id: 'p1', design_memo: '' },
|
|
940
|
+
{ task_id: 't3', title: 'Third task', phase_id: 'p2', design_memo: '' },
|
|
938
941
|
],
|
|
939
942
|
// from is the prerequisite; to starts after from is done.
|
|
940
943
|
hard_dependencies: [{ from: { task_id: 't1' }, to: { task_id: 't3' } }],
|
|
@@ -39,15 +39,17 @@ export function isAuditPendingPhaseStatus(status) {
|
|
|
39
39
|
* 呼ぶ前に`isAuditPendingPhaseStatus`で絞ること。
|
|
40
40
|
*
|
|
41
41
|
* `slotCount`は必須evidence slotの数。1つなら`--evidence`で足り、複数なら`--input`が要る。
|
|
42
|
+
* `auditRequired`(`phaseAuditRequired`)ならclose-unauditedを案内しない(ADR 0200 gate 5が断る)。
|
|
42
43
|
*
|
|
43
44
|
* @returns {string[]} 実行可能なコマンド行(1つ以上)
|
|
44
45
|
*/
|
|
45
|
-
export function auditPendingNextCommands(planKey, phaseId, status, slotCount = 1) {
|
|
46
|
+
export function auditPendingNextCommands(planKey, phaseId, status, slotCount = 1, { auditRequired = false } = {}) {
|
|
46
47
|
const target = `--plan ${planKey} --phase ${phaseId}`;
|
|
47
48
|
if (status === 'gate_ready') {
|
|
48
49
|
return [
|
|
49
50
|
`lattice todo phase review ${target} --reason <text>`,
|
|
50
|
-
|
|
51
|
+
// ADR 0200 gate 5 refuses close-unaudited here, so it is not offered.
|
|
52
|
+
...(auditRequired ? [] : [`lattice todo phase close-unaudited ${target} --reason <text>`]),
|
|
51
53
|
];
|
|
52
54
|
}
|
|
53
55
|
if (status === 'reviewing') {
|
|
@@ -65,6 +67,11 @@ export function auditPendingNextCommands(planKey, phaseId, status, slotCount = 1
|
|
|
65
67
|
throw error;
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
/** ADR 0200 gate 5: an `enforced` plan keeps the audit its author required for a `heavy` phase. */
|
|
71
|
+
export function phaseAuditRequired(member, gatePolicy) {
|
|
72
|
+
return member?.coordination?.mode === 'enforced' && gatePolicy === 'heavy';
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
/**
|
|
69
76
|
* store read model(`lattice.todo_store_read.v1`)の中の監査待ちPhaseを列挙する。
|
|
70
77
|
*
|
|
@@ -197,8 +197,9 @@ export function repairAuthoringArtifact(value) {
|
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
199
|
* 機械が出せる事実を作成入力へ補う(u03p A81/A80)。AIは意図(tasks・依存)だけを書く:
|
|
200
|
-
* actorは席の解決値、recorded_at
|
|
201
|
-
* input_digest
|
|
200
|
+
* actorは席の解決値、recorded_atは現在時刻、配列は正準順、
|
|
201
|
+
* input_digestは再計算。欠けた設計メモは補わず、validatorが欄名で断る(ADR 0181 8)。
|
|
202
|
+
* 作成入力でない値と、レコードでない値はそのまま返す。
|
|
202
203
|
*/
|
|
203
204
|
export const DEFAULT_EVIDENCE_SLOT = 'acceptance';
|
|
204
205
|
export const DEFAULT_CREATE_INPUT_SCHEMA = 'lattice.plan_create_input.v5';
|
|
@@ -279,10 +280,6 @@ export function completeCreateInput(value, { env, now, projectId, planVersion })
|
|
|
279
280
|
if (next.schema === DEFAULT_CREATE_INPUT_SCHEMA && filled.done_condition === undefined) {
|
|
280
281
|
filled.done_condition = null;
|
|
281
282
|
}
|
|
282
|
-
if (memoInput && (absent(filled.design_memo)
|
|
283
|
-
|| (typeof filled.design_memo === 'string' && filled.design_memo.trim() === ''))) {
|
|
284
|
-
filled.design_memo = 'NO_PLAN';
|
|
285
|
-
}
|
|
286
283
|
return filled;
|
|
287
284
|
});
|
|
288
285
|
if (phaseInput) {
|
package/src/todo-cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { cliCommandKind } from './cli-command-kind.mjs';
|
|
|
3
3
|
import { cliFailureClass } from './cli-failure-class.mjs';
|
|
4
4
|
import { FLAG_PLACEHOLDER, publicRefusalCode, withRefusalGuidance } from './cli-refusal-guidance.mjs';
|
|
5
5
|
import { readTaskBackchainContext } from './plan-backchain.mjs';
|
|
6
|
-
import { auditPendingNextCommands } from './todo-audit-pending.mjs';
|
|
6
|
+
import { auditPendingNextCommands, phaseAuditRequired } from './todo-audit-pending.mjs';
|
|
7
7
|
import { gitSync } from './git-process.mjs';
|
|
8
8
|
import { createHash } from 'node:crypto';
|
|
9
9
|
import {
|
|
@@ -173,7 +173,7 @@ import { applySeamProposal } from './seam-apply.mjs';
|
|
|
173
173
|
import { todoPlanPrecedences } from './seam-verification.mjs';
|
|
174
174
|
import {
|
|
175
175
|
WITNESS_DRAFT_SCHEMA, buildWitnessObservationQuerySet, buildWitnessSet, explainWitnessDraft, serializeWitnessSet,
|
|
176
|
-
witnessDraftTemplate,
|
|
176
|
+
validateWitnessDraft, witnessDraftTemplate,
|
|
177
177
|
} from './witness-scaffold.mjs';
|
|
178
178
|
import {
|
|
179
179
|
completePhaseTodoRevision, explainPhaseTodoRevision, explainTodoRevision, explainTodoRevisionSet,
|
|
@@ -348,6 +348,8 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
348
348
|
'independence compile': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
349
349
|
'independence mode': Object.freeze({ known: ['plan', 'set', 'reason'], required: ['plan', 'set', 'reason'] }),
|
|
350
350
|
'independence witness scaffold': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
351
|
+
'independence witness declare': Object.freeze({
|
|
352
|
+
known: ['plan', 'task', 'owns', 'reads', 'writes'], required: ['plan', 'task'] }),
|
|
351
353
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
352
354
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
353
355
|
'phase status': Object.freeze({ known: ['plan', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
@@ -522,12 +524,12 @@ function supportsAtomicStoreCommit(argv) {
|
|
|
522
524
|
if (command === 'note') return argv[1] !== 'list';
|
|
523
525
|
if (command === 'independence') {
|
|
524
526
|
return argv[1] === 'mode'
|
|
525
|
-
|| (argv[1] === 'witness' && ['migrate', 'scaffold'].includes(argv[2]) && !argv.includes('--template'));
|
|
527
|
+
|| (argv[1] === 'witness' && ['migrate', 'scaffold', 'declare'].includes(argv[2]) && !argv.includes('--template'));
|
|
526
528
|
}
|
|
527
529
|
if (command === 'snapshot') return argv[1] === '--rebuild';
|
|
528
530
|
if (command === 'migrate') return !argv.includes('--dry-run') && !argv.includes('--schema');
|
|
529
531
|
if (['revise', 'split', 'revise-set', 'revise-phase', 'start', 'retract', 'block',
|
|
530
|
-
'unblock', 'retire', 'done', 'reopen'].includes(command)) return true;
|
|
532
|
+
'unblock', 'retire', 'done', 'reopen', 'add'].includes(command)) return true;
|
|
531
533
|
if (command === 'evidence') return argv[1] === 'promote';
|
|
532
534
|
if (command === 'phase') return argv[1] !== 'status';
|
|
533
535
|
return false;
|
|
@@ -856,10 +858,13 @@ async function readStructureSetDraft(repoRoot, inputRef) {
|
|
|
856
858
|
* gate_readyの次の一歩を1行で言う(ADR 0148裁定8・a22)。全taskが終わった席には、軽い出口
|
|
857
859
|
* (監査せず閉じるclose-unaudited)を先に、監査する道(review→accept)を後に示す。経緯の説明は載せない。
|
|
858
860
|
*/
|
|
859
|
-
function auditGateGuidance(planKey, phaseId) {
|
|
861
|
+
function auditGateGuidance(planKey, phaseId, auditRequired = false) {
|
|
860
862
|
const target = `--plan ${planKey} --phase ${phaseId}`;
|
|
863
|
+
const audit = `lattice todo phase review ${target} --reason <text> → accept ${target} --evidence <file>`;
|
|
864
|
+
// ADR 0200 gate 5: an enforced plan's heavy phase refuses close-unaudited, so only the audit is offered.
|
|
865
|
+
if (auditRequired) return `全ToDoがdone。このplanはenforcedでheavyの段階なので監査する: ${audit}`;
|
|
861
866
|
return `全ToDoがdone。監査せず閉じるなら: lattice todo phase close-unaudited ${target} --reason <text>`
|
|
862
|
-
+ `(監査するなら
|
|
867
|
+
+ `(監査するなら ${audit})`;
|
|
863
868
|
}
|
|
864
869
|
|
|
865
870
|
/** a36: reviewing and rejected phases say their next command too (the same lines as audit_pending). */
|
|
@@ -1387,6 +1392,9 @@ async function startTask({
|
|
|
1387
1392
|
const advisory = await startAdvisory({
|
|
1388
1393
|
repoRoot, store, projection, planKey, taskId: resolvedTaskId,
|
|
1389
1394
|
});
|
|
1395
|
+
if (member.coordination?.mode === 'enforced') {
|
|
1396
|
+
enforcedStartGate({ advisory, planKey, taskId: resolvedTaskId, overrideReason });
|
|
1397
|
+
}
|
|
1390
1398
|
const structureContext = await startStructureContext({
|
|
1391
1399
|
repoRoot, store, planKey, taskId: resolvedTaskId,
|
|
1392
1400
|
});
|
|
@@ -1406,6 +1414,47 @@ async function startTask({
|
|
|
1406
1414
|
structureContext, featureContext });
|
|
1407
1415
|
}
|
|
1408
1416
|
|
|
1417
|
+
const declareCommand = (planKey, taskId) => `lattice todo independence witness declare --plan ${planKey} --task ${taskId}`
|
|
1418
|
+
+ ' --owns <path>[,<path>...] [--reads <path>,...] [--writes <path>,...]';
|
|
1419
|
+
|
|
1420
|
+
/** ADR 0200 gates 1–3: an enforced plan does not start undeclared, stale or conflicting work. Reads the advisory only. */
|
|
1421
|
+
function enforcedStartGate({ advisory, planKey, taskId, overrideReason }) {
|
|
1422
|
+
const unknown = (kind) => advisory.self_unknowns.some((entry) => entry.kind === kind);
|
|
1423
|
+
const refuse = (reason, detail) => {
|
|
1424
|
+
throw new TodoStoreError('TODO_TRANSITION_REFUSED', reason, undefined, { plan_key: planKey, task_id: taskId, ...detail });
|
|
1425
|
+
};
|
|
1426
|
+
if (advisory.coverage === 'missing' || unknown('witness_missing')) {
|
|
1427
|
+
refuse('enforced_witness_undeclared', { next_action: `Declare the files ${taskId} touches, then start again: \`${declareCommand(planKey, taskId)}\`.` });
|
|
1428
|
+
}
|
|
1429
|
+
if (advisory.drift_intersecting === true || unknown('record_stale')) {
|
|
1430
|
+
refuse('enforced_witness_stale', { next_action: `Main changed under ${taskId}'s declared files since the check: declare them again (it recompiles), then start: \`${declareCommand(planKey, taskId)}\`.` });
|
|
1431
|
+
}
|
|
1432
|
+
if (advisory.conflicts_with_active.length > 0 && overrideReason === null) {
|
|
1433
|
+
const active = advisory.conflicts_with_active.map(({ active_task_id: id }) => id);
|
|
1434
|
+
refuse('enforced_conflict_with_active', { conflicts_with_active: advisory.conflicts_with_active,
|
|
1435
|
+
next_action: `${taskId} overlaps in-progress ${active.join(', ')}: wait for it with \`lattice todo dependency connect --from-plan ${planKey} --from-task ${active[0]} --to-plan ${planKey} --to-task ${taskId} --reason <text>\`,`
|
|
1436
|
+
+ ` or start anyway with \`lattice todo start --plan ${planKey} --task ${taskId} --override-reason <text>\` (the reason is recorded).` });
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
/** ADR 0200 gate 4: done on an enforced plan names the change: evidence, an http(s) URL, or a commit in HEAD. */
|
|
1441
|
+
async function enforcedDoneGate({ repoRoot, planKey, flags }) {
|
|
1442
|
+
const member = (await readTodoStore({ repoRoot })).members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
1443
|
+
if (member?.coordination?.mode !== 'enforced' || flags.evidence !== undefined) return;
|
|
1444
|
+
const message = typeof flags.message === 'string' ? flags.message : '';
|
|
1445
|
+
if (/https?:\/\/\S+/u.test(message)) return;
|
|
1446
|
+
for (const token of message.match(/\b[0-9a-f]{7,40}\b/gu) ?? []) {
|
|
1447
|
+
try {
|
|
1448
|
+
gitSync(['merge-base', '--is-ancestor', token, 'HEAD'], { cwd: repoRoot, stdio: 'ignore' });
|
|
1449
|
+
return;
|
|
1450
|
+
} catch { /* not a commit in HEAD; try the next token */ }
|
|
1451
|
+
}
|
|
1452
|
+
throw new TodoStoreError('TODO_TRANSITION_REFUSED', 'enforced_done_reference_missing', undefined, {
|
|
1453
|
+
plan_key: planKey, task_id: flags.task,
|
|
1454
|
+
next_action: `Name the adopted change: \`lattice todo done --plan ${planKey} --task ${flags.task} --message "<PR URL or merged commit sha>"\` (a sha must be in HEAD).`,
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1409
1458
|
// plan改訂でcarryされたin-progress ToDoの再束縛入口(ADR 0191)。task状態・開始時刻は
|
|
1410
1459
|
// 変えず、現plan_version・現actorのstart束縛だけをjournalへ積む。runtime intakeは
|
|
1411
1460
|
// literal startだけを束縛に使いcarryを推定しないため、改訂を跨いだ進行中工程の
|
|
@@ -1565,6 +1614,19 @@ async function phaseDecisionFromEvidence({ repoRoot, env, planKey, phaseId, outc
|
|
|
1565
1614
|
}
|
|
1566
1615
|
|
|
1567
1616
|
async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload }) {
|
|
1617
|
+
if (kind === 'phase_close_unaudited') {
|
|
1618
|
+
// ADR 0200 gate 5: an enforced plan keeps the audit its author required for a heavy phase.
|
|
1619
|
+
const member = (await readTodoStore({ repoRoot })).members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
1620
|
+
const phase = member === undefined ? undefined
|
|
1621
|
+
: todoPhaseDefinitions(member.plan).find(({ phase_id: id }) => id === phaseId);
|
|
1622
|
+
if (phaseAuditRequired(member, phase?.gate_policy)) {
|
|
1623
|
+
throw new TodoStoreError('TODO_TRANSITION_REFUSED', 'enforced_heavy_phase_unaudited', undefined, {
|
|
1624
|
+
plan_key: planKey, phase_id: phaseId,
|
|
1625
|
+
next_action: `Audit it: \`lattice todo phase review --plan ${planKey} --phase ${phaseId} --reason <text>\` then \`lattice todo phase accept --plan ${planKey} --phase ${phaseId} --evidence <file>\`;`
|
|
1626
|
+
+ ' or revise the phase to a non-heavy gate_policy with `lattice plan revise` (recorded).',
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1568
1630
|
const { event, snapshot, phases } = await appendTodoEvent({
|
|
1569
1631
|
validateProspectiveEvent,
|
|
1570
1632
|
repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }), planKey,
|
|
@@ -1677,6 +1739,15 @@ async function addTask({ repoRoot, env, planKey, flags }) {
|
|
|
1677
1739
|
next_action: `${planKey}/${taskId} already exists: pick an unused --task id (see \`lattice plan show ${planKey} --json\`), or change the task with \`lattice plan revise --input <file>\`.`,
|
|
1678
1740
|
});
|
|
1679
1741
|
}
|
|
1742
|
+
// The same design-memo rule as plan create, named by the flag: a missing memo is not recorded as NO_PLAN.
|
|
1743
|
+
const memo = explainTodoDesignMemo(flags['design-memo']);
|
|
1744
|
+
if (!memo.valid) {
|
|
1745
|
+
throw new TodoStoreError('DESIGN_MEMO_REQUIRED', 'todo_add_design_memo_required', undefined, {
|
|
1746
|
+
plan_key: planKey, task_id: taskId, pointer: '--design-memo', violation_kind: memo.reason,
|
|
1747
|
+
expected: memo.expected, actual: memo.actual, prompt: TODO_DESIGN_MEMO_PROMPT,
|
|
1748
|
+
next_action: `lattice todo add --plan ${planKey} --task ${taskId} --title <text> --design-memo <Markdown, or NO_PLAN>`,
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1680
1751
|
const ids = (value) => (typeof value === 'string' ? value.split(',').map((id) => id.trim()).filter(Boolean) : []);
|
|
1681
1752
|
const after = ids(flags.after);
|
|
1682
1753
|
const before = ids(flags.before);
|
|
@@ -1905,7 +1976,8 @@ async function phaseStatus({ repoRoot, planKey }) {
|
|
|
1905
1976
|
? staleAcceptanceGuidance(member.plan.plan_key, phase.phase_id)
|
|
1906
1977
|
: phase.status === 'gate_ready'
|
|
1907
1978
|
? [
|
|
1908
|
-
auditGateGuidance(member.plan.plan_key, phase.phase_id
|
|
1979
|
+
auditGateGuidance(member.plan.plan_key, phase.phase_id, phaseAuditRequired(member,
|
|
1980
|
+
todoPhaseDefinitions(member.plan).find(({ phase_id: id }) => id === phase.phase_id)?.gate_policy)),
|
|
1909
1981
|
...(structureFinalization.required && structureFinalization.status !== 'fresh'
|
|
1910
1982
|
? [`構造finalizationが${structureFinalization.status}です。先に lattice todo structure finalize --plan ${member.plan.plan_key} --json を実行してください。`]
|
|
1911
1983
|
: []),
|
|
@@ -2094,7 +2166,7 @@ async function migrate({ repoRoot, inputRef }) {
|
|
|
2094
2166
|
coordination_guidance: imported.connectionOnly === true ? null : {
|
|
2095
2167
|
mode: null,
|
|
2096
2168
|
modes: [...TODO_COORDINATION_MODES],
|
|
2097
|
-
next_action: `lattice todo independence mode --plan ${imported.plan.plan_key} --set <witness|conversation> --reason <text>`,
|
|
2169
|
+
next_action: `lattice todo independence mode --plan ${imported.plan.plan_key} --set <witness|conversation|enforced> --reason <text>`,
|
|
2098
2170
|
},
|
|
2099
2171
|
companion,
|
|
2100
2172
|
result_digest: '',
|
|
@@ -3659,6 +3731,11 @@ async function witnessScaffold({ repoRoot, planKey, inputRef }) {
|
|
|
3659
3731
|
draft_plan_key: draft.plan_key, plan_key: planKey,
|
|
3660
3732
|
});
|
|
3661
3733
|
}
|
|
3734
|
+
return scaffoldWitnessDraft({ repoRoot, planKey, draft });
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
/** The scaffold itself: fresh observation, wiring and digest for a checked draft, then the write. */
|
|
3738
|
+
async function scaffoldWitnessDraft({ repoRoot, planKey, draft }) {
|
|
3662
3739
|
const { queries, paths } = buildWitnessObservationQuerySet(draft);
|
|
3663
3740
|
const collected = await collectSensorEvidence({ cwd: repoRoot, querySet: { queries } });
|
|
3664
3741
|
const observationByPath = {};
|
|
@@ -3698,6 +3775,53 @@ async function witnessScaffold({ repoRoot, planKey, inputRef }) {
|
|
|
3698
3775
|
};
|
|
3699
3776
|
}
|
|
3700
3777
|
|
|
3778
|
+
/**
|
|
3779
|
+
* a40: one task's witness row, declared by its member. Rows nobody declared stay out (an empty row
|
|
3780
|
+
* would claim "touches nothing"); compile runs once every ready task is declared.
|
|
3781
|
+
*/
|
|
3782
|
+
async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
3783
|
+
const store = await readTodoStore({ repoRoot });
|
|
3784
|
+
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
3785
|
+
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
3786
|
+
const taskId = flags.task;
|
|
3787
|
+
const state = member.tasks.find(({ task_id: id }) => id === taskId);
|
|
3788
|
+
if (state === undefined) {
|
|
3789
|
+
throw new TodoStoreError('TASK_NOT_FOUND', 'task_not_found', undefined, { requested_task_id: taskId });
|
|
3790
|
+
}
|
|
3791
|
+
if (['done', 'retired'].includes(state.status)) {
|
|
3792
|
+
throw new TodoStoreError('INPUT_INVALID', 'witness_declare_task_finished', undefined, {
|
|
3793
|
+
plan_key: planKey, task_id: taskId, status: state.status,
|
|
3794
|
+
next_action: `${planKey}/${taskId} is ${state.status}; only unfinished tasks are declared (see \`lattice todo status --json\`).`,
|
|
3795
|
+
});
|
|
3796
|
+
}
|
|
3797
|
+
const recorded = await readTodoWitnessSet({ repoRoot, planKey }).catch(() => null);
|
|
3798
|
+
const template = await witnessDraftTemplateFor({ repoRoot, planKey });
|
|
3799
|
+
const keep = new Set([...Object.keys(recorded?.plan_key === planKey ? recorded.manual_witness : {}), taskId]);
|
|
3800
|
+
const list = (value) => (typeof value === 'string' ? value.split(',').map((item) => item.trim()).filter(Boolean) : []);
|
|
3801
|
+
const row = { owns: list(flags.owns), reads: list(flags.reads), writes: list(flags.writes) };
|
|
3802
|
+
const draft = { ...template, tasks: Object.fromEntries(Object.entries(template.tasks)
|
|
3803
|
+
.filter(([id]) => keep.has(id)).map(([id, task]) => [id, id === taskId ? row : task])) };
|
|
3804
|
+
if (!validateWitnessDraft(draft)) {
|
|
3805
|
+
const { valid: _valid, reason, path: at, ...keys } = explainWitnessDraft(draft);
|
|
3806
|
+
throw new TodoStoreError('WITNESS_DRAFT_INVALID', reason, undefined, {
|
|
3807
|
+
pointer: at, ...keys, next_action: witnessRoute(planKey) });
|
|
3808
|
+
}
|
|
3809
|
+
const scaffolded = await scaffoldWitnessDraft({ repoRoot, planKey, draft });
|
|
3810
|
+
const waitingFor = projectTodoStatus(await readTodoStore({ repoRoot }), TODO_STATUS_DISPATCH_ONLY).next_ready
|
|
3811
|
+
.filter((task) => task.plan_key === planKey && !keep.has(task.task_id))
|
|
3812
|
+
.map(({ task_id: id }) => id).sort();
|
|
3813
|
+
const compile = waitingFor.length === 0
|
|
3814
|
+
? await independenceCompile({ repoRoot, planKey, inputRef: scaffolded.witness_ref }) : null;
|
|
3815
|
+
const result = {
|
|
3816
|
+
schema: 'lattice.todo_witness_declare_result.v1', project_id: member.plan.project_id, plan_key: planKey,
|
|
3817
|
+
task_id: taskId, ...row, witness_ref: scaffolded.witness_ref,
|
|
3818
|
+
witness_set_digest: scaffolded.witness_set_digest, compiled: compile !== null, waiting_for: waitingFor,
|
|
3819
|
+
compile, result_digest: '',
|
|
3820
|
+
};
|
|
3821
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
3822
|
+
return result;
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3701
3825
|
/**
|
|
3702
3826
|
* 着地時に使うsurface名。提案が出すhash由来の仮名を、人が読む名前へ置き換える。
|
|
3703
3827
|
*
|
|
@@ -4396,7 +4520,7 @@ function writesTodoStore(argv) {
|
|
|
4396
4520
|
case 'migrate': return !argv.includes('--dry-run');
|
|
4397
4521
|
case 'snapshot': return argv.includes('--rebuild');
|
|
4398
4522
|
case 'independence': return second === 'compile' || second === 'mode'
|
|
4399
|
-
|| (second === 'witness' && ['migrate', 'scaffold'].includes(third) && !argv.includes('--template'));
|
|
4523
|
+
|| (second === 'witness' && ['migrate', 'scaffold', 'declare'].includes(third) && !argv.includes('--template'));
|
|
4400
4524
|
case 'structure': return ['compile', 'realize', 'finalize'].includes(second)
|
|
4401
4525
|
|| (second === 'input' && !argv.includes('--dry-run'));
|
|
4402
4526
|
case 'seam-proposal': return ['compile', 'apply', 'land'].includes(second);
|
|
@@ -4404,7 +4528,7 @@ function writesTodoStore(argv) {
|
|
|
4404
4528
|
case 'dependency': return ['connect', 'disconnect'].includes(second);
|
|
4405
4529
|
case 'phase': return second !== 'status';
|
|
4406
4530
|
case 'start': case 'retract': case 'block': case 'unblock': case 'retire': case 'done':
|
|
4407
|
-
case 'reopen': case 'split': case 'revise': case 'revise-phase': case 'revise-set':
|
|
4531
|
+
case 'reopen': case 'split': case 'revise': case 'revise-phase': case 'revise-set': case 'add':
|
|
4408
4532
|
return true;
|
|
4409
4533
|
default: return false;
|
|
4410
4534
|
}
|
|
@@ -4809,6 +4933,12 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4809
4933
|
if (flags !== null && isTodoIdentifier(flags.plan)) {
|
|
4810
4934
|
action = (repoRoot) => witnessDraftTemplateFor({ repoRoot, planKey: flags.plan });
|
|
4811
4935
|
}
|
|
4936
|
+
} else if (argv[0] === 'independence' && argv[1] === 'witness' && argv[2] === 'declare') {
|
|
4937
|
+
const flags = matchFlagCommand(argv, ['independence', 'witness', 'declare'],
|
|
4938
|
+
TODO_FLAG_SPECS['independence witness declare']);
|
|
4939
|
+
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4940
|
+
action = (repoRoot) => witnessDeclare({ repoRoot, planKey: flags.plan, flags });
|
|
4941
|
+
}
|
|
4812
4942
|
} else if (argv[0] === 'independence' && argv[1] === 'witness' && argv[2] === 'scaffold') {
|
|
4813
4943
|
const flags = matchFlagCommand(argv, ['independence', 'witness', 'scaffold'],
|
|
4814
4944
|
TODO_FLAG_SPECS['independence witness scaffold']);
|
|
@@ -4973,11 +5103,14 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4973
5103
|
&& (flags['test-result'] === undefined || isAuthoringPathToken(flags['test-result']))) {
|
|
4974
5104
|
action = (repoRoot) => mutateUnlessUnchanged({ repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4975
5105
|
kind: 'done', dropped: (recorded) => doneDropped({ repoRoot, flags, recorded }),
|
|
4976
|
-
action: async () =>
|
|
4977
|
-
repoRoot,
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
5106
|
+
action: async () => {
|
|
5107
|
+
await enforcedDoneGate({ repoRoot, planKey: flags.plan, flags });
|
|
5108
|
+
return mutate({
|
|
5109
|
+
repoRoot, env, planKey: flags.plan, taskId: flags.task, kind: 'done', payload: 'authored',
|
|
5110
|
+
...await doneEvidenceInput({ repoRoot, flags }),
|
|
5111
|
+
testResultRef: flags['test-result'] ?? null,
|
|
5112
|
+
});
|
|
5113
|
+
} });
|
|
4981
5114
|
}
|
|
4982
5115
|
}
|
|
4983
5116
|
if (action === null && argv[0] === 'retract') {
|
package/src/todo-contracts.mjs
CHANGED
|
@@ -27,7 +27,8 @@ export const TODO_PLAN_SCOPED_EVENT_KINDS = Object.freeze([
|
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
29
|
/** 調整方式。witness=独立性を宣言し検証して並列する/conversation=会話で調整する。 */
|
|
30
|
-
|
|
30
|
+
// ADR 0200: `enforced` is witness coordination plus the gates that stop skipped steps.
|
|
31
|
+
export const TODO_COORDINATION_MODES = Object.freeze(['witness', 'conversation', 'enforced']);
|
|
31
32
|
export const TODO_NOTE_EVENT_SCHEMA = 'lattice.todo_note_event.v1';
|
|
32
33
|
/**
|
|
33
34
|
* plan単位のnote event。工程レベルの義務(順序制約・一度きりの観測が在ること)は特定のtaskに
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TODO_COORDINATION_MODES } from './todo-contracts.mjs';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 並列可否の案内(ADR 0130)。
|
|
3
5
|
*
|
|
@@ -72,7 +74,7 @@ const CATALOG = Object.freeze({
|
|
|
72
74
|
}),
|
|
73
75
|
coordination_mode_undeclared: Object.freeze({
|
|
74
76
|
message: 'このplanは調整方式をまだ選んでいない。witness検証で並列するか、会話で調整するかが決まっていない。',
|
|
75
|
-
next_action: 'lattice todo independence mode --plan <key> --set <witness|conversation> --reason <text>',
|
|
77
|
+
next_action: 'lattice todo independence mode --plan <key> --set <witness|conversation|enforced> --reason <text>',
|
|
76
78
|
}),
|
|
77
79
|
coordination_conversation: Object.freeze({
|
|
78
80
|
message: 'このplanは会話調整を選んでいる。並列可否は宣言と判定ではなく、卓の合意が持つ。',
|
|
@@ -192,7 +194,7 @@ export function todoIndependenceGuidance(code, { severability = null, planKey =
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
export function pullIntakeReadinessGuidance({ coordinationMode = null, ready, planKey = null }) {
|
|
195
|
-
if (!
|
|
197
|
+
if (!(coordinationMode === null || TODO_COORDINATION_MODES.includes(coordinationMode))
|
|
196
198
|
|| typeof ready !== 'boolean') {
|
|
197
199
|
throw new TypeError('pull intake readiness input is invalid');
|
|
198
200
|
}
|
package/src/todo-status.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AUDIT_PENDING_PHASE_STATUSES,
|
|
5
5
|
auditPendingNextCommands,
|
|
6
6
|
isAuditPendingPhaseStatus,
|
|
7
|
+
phaseAuditRequired,
|
|
7
8
|
} from './todo-audit-pending.mjs';
|
|
8
9
|
import {
|
|
9
10
|
TODO_COORDINATION_MODES,
|
|
@@ -414,7 +415,8 @@ function collectAuditPending(member, sink) {
|
|
|
414
415
|
implicit,
|
|
415
416
|
required_evidence_slots: [...definition.required_evidence_slots],
|
|
416
417
|
next_commands: auditPendingNextCommands(member.plan.plan_key, phase.phase_id, phase.status,
|
|
417
|
-
definition.required_evidence_slots.length
|
|
418
|
+
definition.required_evidence_slots.length,
|
|
419
|
+
{ auditRequired: phaseAuditRequired(member, definition.gate_policy) }),
|
|
418
420
|
});
|
|
419
421
|
}
|
|
420
422
|
}
|