@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
|
@@ -510,10 +510,13 @@ function activeConflictEntry(value) {
|
|
|
510
510
|
* 案内。単一正本のcatalogが返した形をそのまま載せる(ADR 0130 Decision 1・2)。
|
|
511
511
|
* 面ごとに文言を組み立て直さないため、ここではshapeだけを検査する。
|
|
512
512
|
*/
|
|
513
|
+
// next_actionは実在コマンド(`lattice ...`)か'none'(a19)。
|
|
514
|
+
const commandOrNone = (value) => value === 'none' || (boundedText(value) && value.startsWith('lattice '));
|
|
515
|
+
|
|
513
516
|
function guidanceEntry(value) {
|
|
514
517
|
return exactRecord(value, ['code', 'message', 'next_action'])
|
|
515
518
|
&& TODO_INDEPENDENCE_GUIDANCE_CODES.includes(value.code)
|
|
516
|
-
&& boundedText(value.message) &&
|
|
519
|
+
&& boundedText(value.message) && commandOrNone(value.next_action);
|
|
517
520
|
}
|
|
518
521
|
|
|
519
522
|
/**
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* 文は事実と次の一歩だけを述べ、指示しない。どのreadyを取るかはhostが所有する
|
|
8
8
|
* (ADR 0063 Decision 5)。命令形にするとLatticeがagentを統制する面へ滑る。
|
|
9
9
|
* 未検証の工程も start は拒否しない(u03 B1–B6、ADR 0182 を置き換える)。助言として返す。
|
|
10
|
+
* next_actionは実在するコマンドか'none'だけ(a19)。planKeyを渡すと`<key>`が置き換わる。
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
export const TODO_INDEPENDENCE_GUIDANCE_CODES = Object.freeze([
|
|
@@ -71,7 +72,7 @@ const CATALOG = Object.freeze({
|
|
|
71
72
|
}),
|
|
72
73
|
coordination_mode_undeclared: Object.freeze({
|
|
73
74
|
message: 'このplanは調整方式をまだ選んでいない。witness検証で並列するか、会話で調整するかが決まっていない。',
|
|
74
|
-
next_action: '
|
|
75
|
+
next_action: 'lattice todo independence mode --plan <key> --set <witness|conversation> --reason <text>',
|
|
75
76
|
}),
|
|
76
77
|
coordination_conversation: Object.freeze({
|
|
77
78
|
message: 'このplanは会話調整を選んでいる。並列可否は宣言と判定ではなく、卓の合意が持つ。',
|
|
@@ -79,35 +80,35 @@ const CATALOG = Object.freeze({
|
|
|
79
80
|
}),
|
|
80
81
|
independence_unrecorded: Object.freeze({
|
|
81
82
|
message: 'このplanの並列可否はまだ判定していない。競合が無いのではなく、記録が存在しない。',
|
|
82
|
-
next_action: '
|
|
83
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
83
84
|
}),
|
|
84
85
|
independence_task_undeclared: Object.freeze({
|
|
85
86
|
message: 'この工程はwitness setで宣言されていないため、記録には含まれていない。',
|
|
86
|
-
next_action: '
|
|
87
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
87
88
|
}),
|
|
88
89
|
independence_contract_superseded: Object.freeze({
|
|
89
90
|
message: '記録は旧契約versionで書かれており、現在の並列可否の判定としては読めない。現在の契約での再compileが次の一歩になる。',
|
|
90
|
-
next_action: '
|
|
91
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
91
92
|
}),
|
|
92
93
|
independence_superseded: Object.freeze({
|
|
93
94
|
message: 'planが改訂され、記録は別のtopologyについての判定になっている。',
|
|
94
|
-
next_action: '
|
|
95
|
+
next_action: 'lattice todo independence witness migrate --plan <key>',
|
|
95
96
|
}),
|
|
96
97
|
independence_stale_for_task: Object.freeze({
|
|
97
98
|
message: '記録後にこの工程の宣言境界が変更されたため、記録時点の判定は現在のcodeを指していない。',
|
|
98
|
-
next_action: '
|
|
99
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
99
100
|
}),
|
|
100
101
|
independence_conflict_with_active: Object.freeze({
|
|
101
102
|
message: '作業中の工程と同じ資源を書く記録がある。並行すると衝突する。',
|
|
102
|
-
next_action: '
|
|
103
|
+
next_action: 'lattice todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
103
104
|
}),
|
|
104
105
|
independence_conflict_between_ready: Object.freeze({
|
|
105
106
|
message: '他のready工程と同じ資源を書く記録がある。同時に着手すると衝突する。',
|
|
106
|
-
next_action: '
|
|
107
|
+
next_action: 'lattice todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
107
108
|
}),
|
|
108
109
|
independence_verdicts_absent: Object.freeze({
|
|
109
110
|
message: '判定が途中で止まっており、記録はどの組についてもverdictを持たない。自分にunknownが無いことは、他と干渉しない証拠にならない。',
|
|
110
|
-
next_action: '
|
|
111
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
111
112
|
}),
|
|
112
113
|
independence_verified: Object.freeze({
|
|
113
114
|
message: '記録時点の宣言境界では、他のready工程と干渉しない。',
|
|
@@ -115,39 +116,39 @@ const CATALOG = Object.freeze({
|
|
|
115
116
|
}),
|
|
116
117
|
seam_proposal_unrecorded: Object.freeze({
|
|
117
118
|
message: 'このplanのseam提案はまだ生成していない。提案対象が無いのではなく、記録が存在しない。',
|
|
118
|
-
next_action: '
|
|
119
|
+
next_action: 'lattice todo seam-proposal compile --plan <key>',
|
|
119
120
|
}),
|
|
120
121
|
seam_proposal_superseded: Object.freeze({
|
|
121
122
|
message: '参照元のplanまたは並列可否記録が更新され、このseam提案は現在の競合についての記録ではない。',
|
|
122
|
-
next_action: '
|
|
123
|
+
next_action: 'lattice todo seam-proposal compile --plan <key>',
|
|
123
124
|
}),
|
|
124
125
|
seam_proposal_stale: Object.freeze({
|
|
125
126
|
message: 'seam提案の生成後にHEADが進み、記録時点の構造証拠は現在のcodeを指していない。',
|
|
126
|
-
next_action: '
|
|
127
|
+
next_action: 'lattice todo seam-proposal compile --plan <key>',
|
|
127
128
|
}),
|
|
128
129
|
seam_proposal_binding_overlap: Object.freeze({
|
|
129
130
|
message: `同じ資源について、複数のToDoが同じsymbolを自分の担当として宣言している。どちら側へ切るか決まらないため、切断候補を束縛できない。${BINDING_RECOMPILE_HINT}`,
|
|
130
|
-
next_action: '
|
|
131
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
131
132
|
}),
|
|
132
133
|
seam_proposal_binding_outside_resource: Object.freeze({
|
|
133
134
|
message: `concern_anchorsが挙げたsymbolが、withinで指した資源の外にある。その資源の分割を説明しないので束縛へ使えない。${BINDING_RECOMPILE_HINT}`,
|
|
134
|
-
next_action: '
|
|
135
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
135
136
|
}),
|
|
136
137
|
seam_proposal_binding_symbol_unresolved: Object.freeze({
|
|
137
138
|
message: `concern_anchorsが挙げたsymbolを、sensorが同名同pathで解決できなかった。近い別symbolへは寄せないため、束縛は成立していない。${BINDING_RECOMPILE_HINT}`,
|
|
138
|
-
next_action: '
|
|
139
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
139
140
|
}),
|
|
140
141
|
seam_proposal_binding_resource_unresolved: Object.freeze({
|
|
141
142
|
message: `concern_anchorsのwithinが指す資源をsensorで解決できなかった。宣言がどの資源についてのものか確定しない。${BINDING_RECOMPILE_HINT}`,
|
|
142
|
-
next_action: '
|
|
143
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
143
144
|
}),
|
|
144
145
|
seam_proposal_binding_ambiguous: Object.freeze({
|
|
145
146
|
message: `宣言したsymbolが切断候補の複数側へ当たるため、どのToDoがどちらを所有するか一意に決まらない。${BINDING_RECOMPILE_HINT}`,
|
|
146
|
-
next_action: '
|
|
147
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
147
148
|
}),
|
|
148
149
|
seam_proposal_binding_missing: Object.freeze({
|
|
149
150
|
message: `係争資源の中でどのToDoが何を触るかが宣言されていないため、切断候補を所有者へ束縛できない。依存線でも呼び出し辺でも所有は決まらない。${BINDING_RECOMPILE_HINT}`,
|
|
150
|
-
next_action: '
|
|
151
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
151
152
|
}),
|
|
152
153
|
seam_proposal_verified: Object.freeze({
|
|
153
154
|
message: 'seam提案の記録は現在のplan、並列可否記録、HEADと一致している。',
|
|
@@ -159,7 +160,7 @@ const PULL_INTAKE_READINESS = Object.freeze({
|
|
|
159
160
|
required: Object.freeze({
|
|
160
161
|
code: 'pull_independence_required',
|
|
161
162
|
message: 'pull設備のintakeには有効なindependence artifactが必須である。conversation調整はwitness督促を消すが、この実行前提は満たさない。',
|
|
162
|
-
next_action: '
|
|
163
|
+
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
163
164
|
}),
|
|
164
165
|
ready: Object.freeze({
|
|
165
166
|
code: 'pull_independence_ready',
|
|
@@ -174,7 +175,9 @@ const SEVERABILITY_HINT = Object.freeze({
|
|
|
174
175
|
serial: '共有stateまたはeffectの衝突なので、分割では切り離せない。',
|
|
175
176
|
});
|
|
176
177
|
|
|
177
|
-
|
|
178
|
+
const withPlanKey = (command, planKey) => (planKey === null ? command : command.replaceAll('<key>', () => planKey));
|
|
179
|
+
|
|
180
|
+
export function todoIndependenceGuidance(code, { severability = null, planKey = null } = {}) {
|
|
178
181
|
const entry = CATALOG[code];
|
|
179
182
|
if (entry === undefined) {
|
|
180
183
|
throw new TypeError(`unknown independence guidance code: ${code}`);
|
|
@@ -183,17 +186,19 @@ export function todoIndependenceGuidance(code, { severability = null } = {}) {
|
|
|
183
186
|
return {
|
|
184
187
|
code,
|
|
185
188
|
message: hint === null ? entry.message : `${entry.message}${hint}`,
|
|
186
|
-
next_action: entry.next_action,
|
|
189
|
+
next_action: withPlanKey(entry.next_action, planKey),
|
|
187
190
|
};
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
export function pullIntakeReadinessGuidance({ coordinationMode = null, ready }) {
|
|
193
|
+
export function pullIntakeReadinessGuidance({ coordinationMode = null, ready, planKey = null }) {
|
|
191
194
|
if (![null, 'witness', 'conversation'].includes(coordinationMode)
|
|
192
195
|
|| typeof ready !== 'boolean') {
|
|
193
196
|
throw new TypeError('pull intake readiness input is invalid');
|
|
194
197
|
}
|
|
198
|
+
const readiness = ready ? PULL_INTAKE_READINESS.ready : PULL_INTAKE_READINESS.required;
|
|
195
199
|
return {
|
|
196
|
-
...
|
|
200
|
+
...readiness,
|
|
201
|
+
next_action: withPlanKey(readiness.next_action, planKey),
|
|
197
202
|
plan_binding_ready: ready,
|
|
198
203
|
coordination_mode: coordinationMode,
|
|
199
204
|
};
|
|
@@ -238,23 +243,23 @@ export function scopeExpansionRecommendations(scopeExpanded) {
|
|
|
238
243
|
export function selectIndependenceGuidance({
|
|
239
244
|
coverage, taskDeclared, taskStale, conflictWithActive = null, conflictBetweenReady = null,
|
|
240
245
|
contractSuperseded = false, readyCount = null, verdictsAbsent = false,
|
|
241
|
-
coordinationMode = 'witness',
|
|
246
|
+
coordinationMode = 'witness', planKey = null,
|
|
242
247
|
}) {
|
|
243
248
|
// 着手候補が無いなら述べる対象が無い。ここを通さないと、readyが空のとき
|
|
244
249
|
// 「未検査taskが1件も無い」が空虚に真になり、記録が古くても検証済みへ倒れる。
|
|
245
|
-
if (readyCount === 0) return todoIndependenceGuidance('independence_no_ready_frontier');
|
|
250
|
+
if (readyCount === 0) return todoIndependenceGuidance('independence_no_ready_frontier', { planKey });
|
|
246
251
|
if (conflictWithActive !== null) {
|
|
247
252
|
return todoIndependenceGuidance('independence_conflict_with_active', {
|
|
248
|
-
severability: conflictWithActive,
|
|
253
|
+
severability: conflictWithActive, planKey,
|
|
249
254
|
});
|
|
250
255
|
}
|
|
251
256
|
if (conflictBetweenReady !== null) {
|
|
252
257
|
return todoIndependenceGuidance('independence_conflict_between_ready', {
|
|
253
|
-
severability: conflictBetweenReady,
|
|
258
|
+
severability: conflictBetweenReady, planKey,
|
|
254
259
|
});
|
|
255
260
|
}
|
|
256
261
|
if (contractSuperseded) {
|
|
257
|
-
return todoIndependenceGuidance('independence_contract_superseded');
|
|
262
|
+
return todoIndependenceGuidance('independence_contract_superseded', { planKey });
|
|
258
263
|
}
|
|
259
264
|
// 記録が無い時に何を言うかは、planがどちらの方式を選んだかで変わる(ob03・裁定C①)。
|
|
260
265
|
// 会話調整を選んだplanへ未compileを督促するのは、選択を尊重しないことになる。未宣言の
|
|
@@ -262,17 +267,17 @@ export function selectIndependenceGuidance({
|
|
|
262
267
|
// 当のものである。督促が一級で出るのはwitnessを選んだplanだけとする。
|
|
263
268
|
// 既定を`witness`にしてあるのは、宣言を渡さない既存の呼び出し側の挙動を変えないためである。
|
|
264
269
|
if (coverage === 'missing') {
|
|
265
|
-
if (coordinationMode === 'conversation') return todoIndependenceGuidance('coordination_conversation');
|
|
266
|
-
if (coordinationMode === null) return todoIndependenceGuidance('coordination_mode_undeclared');
|
|
267
|
-
return todoIndependenceGuidance('independence_unrecorded');
|
|
270
|
+
if (coordinationMode === 'conversation') return todoIndependenceGuidance('coordination_conversation', { planKey });
|
|
271
|
+
if (coordinationMode === null) return todoIndependenceGuidance('coordination_mode_undeclared', { planKey });
|
|
272
|
+
return todoIndependenceGuidance('independence_unrecorded', { planKey });
|
|
268
273
|
}
|
|
269
|
-
if (coverage === 'superseded') return todoIndependenceGuidance('independence_superseded');
|
|
270
|
-
if (!taskDeclared) return todoIndependenceGuidance('independence_task_undeclared');
|
|
271
|
-
if (taskStale) return todoIndependenceGuidance('independence_stale_for_task');
|
|
274
|
+
if (coverage === 'superseded') return todoIndependenceGuidance('independence_superseded', { planKey });
|
|
275
|
+
if (!taskDeclared) return todoIndependenceGuidance('independence_task_undeclared', { planKey });
|
|
276
|
+
if (taskStale) return todoIndependenceGuidance('independence_stale_for_task', { planKey });
|
|
272
277
|
// 記録は新しく、この工程自身にも問題が無い。それでもverdictが1つも無いなら、
|
|
273
278
|
// 述べられるのは「干渉しない」ではなく「まだ何も判定していない」である。
|
|
274
|
-
if (verdictsAbsent) return todoIndependenceGuidance('independence_verdicts_absent');
|
|
275
|
-
return todoIndependenceGuidance('independence_verified');
|
|
279
|
+
if (verdictsAbsent) return todoIndependenceGuidance('independence_verdicts_absent', { planKey });
|
|
280
|
+
return todoIndependenceGuidance('independence_verified', { planKey });
|
|
276
281
|
}
|
|
277
282
|
|
|
278
283
|
/**
|
|
@@ -292,8 +297,8 @@ export function seamProposalGuidanceCode({ coverage, unknownKinds = [] }) {
|
|
|
292
297
|
return binding === undefined ? 'seam_proposal_verified' : binding[1];
|
|
293
298
|
}
|
|
294
299
|
|
|
295
|
-
export function selectSeamProposalGuidance({ coverage, unknownKinds = [] }) {
|
|
296
|
-
return todoIndependenceGuidance(seamProposalGuidanceCode({ coverage, unknownKinds }));
|
|
300
|
+
export function selectSeamProposalGuidance({ coverage, unknownKinds = [], planKey = null }) {
|
|
301
|
+
return todoIndependenceGuidance(seamProposalGuidanceCode({ coverage, unknownKinds }), { planKey });
|
|
297
302
|
}
|
|
298
303
|
|
|
299
304
|
/**
|
package/src/todo-store.mjs
CHANGED
|
@@ -949,10 +949,20 @@ function validateMergedGraph(members, crossPlanDependencies = projectTodoCrossPl
|
|
|
949
949
|
adjacency.get(from).push(to);
|
|
950
950
|
}
|
|
951
951
|
const colors = new Map();
|
|
952
|
+
const stack = [];
|
|
953
|
+
// a18: name the closed path (first node repeated last), not just that one exists.
|
|
954
|
+
const nodeRef = (key) => {
|
|
955
|
+
const parts = key.split('\0');
|
|
956
|
+
return parts[0] === 'phase' ? { plan_key: parts[2], phase_id: parts[3] } : { plan_key: parts[1], task_id: parts[2] };
|
|
957
|
+
};
|
|
952
958
|
const visit = (node) => {
|
|
953
|
-
if (colors.get(node) === 1)
|
|
959
|
+
if (colors.get(node) === 1) {
|
|
960
|
+
fail('STORE_INCONSISTENT', 'merged_cycle', { cycle: [...stack.slice(stack.indexOf(node)), node].map(nodeRef) });
|
|
961
|
+
}
|
|
954
962
|
if (colors.get(node) === 2) return;
|
|
955
|
-
colors.set(node, 1);
|
|
963
|
+
colors.set(node, 1); stack.push(node);
|
|
964
|
+
for (const next of adjacency.get(node)) visit(next);
|
|
965
|
+
stack.pop(); colors.set(node, 2);
|
|
956
966
|
};
|
|
957
967
|
for (const node of adjacency.keys()) visit(node);
|
|
958
968
|
// A join binds `before` once per member: keep one finding per identity, in code-unit order.
|
|
@@ -1012,7 +1022,7 @@ function validateCrossPlanDependencyTransition(store, owner, input) {
|
|
|
1012
1022
|
validateMergedGraph(store.members, [...existing, { from, to }]);
|
|
1013
1023
|
} catch (error) {
|
|
1014
1024
|
if (error instanceof TodoStoreError && error.detail?.reason === 'merged_cycle') {
|
|
1015
|
-
fail('DEPENDENCY_CYCLE', 'cross_plan_dependency_cycle', { from, to });
|
|
1025
|
+
fail('DEPENDENCY_CYCLE', 'cross_plan_dependency_cycle', { from, to, cycle: error.detail.cycle });
|
|
1016
1026
|
}
|
|
1017
1027
|
throw error;
|
|
1018
1028
|
}
|
|
@@ -2248,7 +2258,7 @@ export async function appendTodoEvent(options = {}) {
|
|
|
2248
2258
|
const target = events.find((entry) => entry.kind === 'cross_plan_dependency'
|
|
2249
2259
|
&& entry.event_digest === digest);
|
|
2250
2260
|
if (target === undefined) {
|
|
2251
|
-
fail('
|
|
2261
|
+
fail('DEPENDENCY_NOT_FOUND', 'cross_plan_dependency_not_found', { target_event_digest: digest });
|
|
2252
2262
|
}
|
|
2253
2263
|
if (events.some((entry) => entry.kind === 'cross_plan_dependency_removed'
|
|
2254
2264
|
&& entry.payload.target_event_digest === digest)) {
|