@quolu/lattice 0.114.4 → 0.116.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/bin/lattice.mjs +22 -3
- package/package.json +1 -1
- package/src/chart-cli.mjs +50 -7
- package/src/cli-help.mjs +6 -3
- package/src/runtime-error-reporting.mjs +119 -105
- package/src/runtime-errors.mjs +37 -9
- package/src/todo-cli.mjs +87 -15
- package/src/todo-external.mjs +6 -1
- package/src/todo-gantt-html-shared.mjs +3 -2
- package/src/todo-note-store.mjs +195 -113
- package/src/todo-readiness.mjs +4 -8
- package/src/todo-store-view.mjs +47 -13
- package/src/todo-store.mjs +172 -3
- package/src/todo-waiters.mjs +62 -0
package/src/runtime-errors.mjs
CHANGED
|
@@ -114,27 +114,55 @@ export function runtimeErrorReportingConfigPath(env = process.env, platform = ho
|
|
|
114
114
|
return join(env.HOME || homedir(), '.config', 'lattice', 'runtime-error-reporting.json');
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/** 署名者の設定(秘密なし)。key_idはBugHubの発行名、commandはargv(shellを通さない)、cwdは認証仲介が呼び出し元として見るfolder。 */
|
|
118
|
+
const SIGNER_KEY_ID = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
119
|
+
const text = (value) => typeof value === 'string' && value.length >= 1 && value.length <= 4096 && !value.includes('\0');
|
|
120
|
+
export function validReportingSigner(value) {
|
|
121
|
+
return plain(value) && exact(value, ['key_id', 'command', 'cwd'])
|
|
122
|
+
&& typeof value.key_id === 'string' && SIGNER_KEY_ID.test(value.key_id)
|
|
123
|
+
&& Array.isArray(value.command) && value.command.length >= 1 && value.command.length <= 64 && value.command.every(text)
|
|
124
|
+
&& (value.cwd === null || text(value.cwd));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function validReportingUrl(value) {
|
|
128
|
+
try {
|
|
129
|
+
const url = new URL(value);
|
|
130
|
+
return typeof value === 'string' && value.length <= 2048 && ['http:', 'https:'].includes(url.protocol) && url.username === '' && url.password === '';
|
|
131
|
+
} catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
117
136
|
/**
|
|
118
|
-
* Lattice自身の送信設定(ADR 0193)。端末で`runtime-errors reporting enable`を打った時だけ有効になる。
|
|
137
|
+
* Lattice自身の送信設定(ADR 0193・0197)。端末で`runtime-errors reporting enable`を打った時だけ有効になる。
|
|
138
|
+
* `signer`(BugHub-ES256の署名者)と`url`(既定の受け口の差し替え)は任意。形の違う`signer`・`url`は無いものとして読む。
|
|
119
139
|
* `LATTICE_RUNTIME_ERROR_REPORTING=0`は既定の置き場を読まない——試験と自動化が、その端末の本物の設定を
|
|
120
140
|
* 拾って送信しないための口。`options.reportingConfigPath`を明示した呼び出しはそのfileを読む。
|
|
141
|
+
* 設定が無い・読めない・形が違う時は`null`。
|
|
121
142
|
*/
|
|
122
|
-
export function
|
|
123
|
-
if (!collectionSupported(options)) return
|
|
143
|
+
export function readRuntimeErrorReportingConfig(options = {}) {
|
|
144
|
+
if (!collectionSupported(options)) return null;
|
|
124
145
|
const env = options.env ?? process.env;
|
|
125
|
-
if (options.reportingConfigPath === undefined && env.LATTICE_RUNTIME_ERROR_REPORTING === '0') return
|
|
146
|
+
if (options.reportingConfigPath === undefined && env.LATTICE_RUNTIME_ERROR_REPORTING === '0') return null;
|
|
126
147
|
try {
|
|
127
148
|
const path = options.reportingConfigPath ?? runtimeErrorReportingConfigPath(env);
|
|
128
149
|
const stats = lstatSync(path);
|
|
129
|
-
if (!stats.isFile() || stats.isSymbolicLink()) return
|
|
150
|
+
if (!stats.isFile() || stats.isSymbolicLink()) return null;
|
|
130
151
|
const config = JSON.parse(readFileSync(path, 'utf8'));
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
if (!plain(config) || !Object.keys(config).every((key) => ['schema', 'enabled', 'signer', 'url'].includes(key))
|
|
153
|
+
|| config.schema !== REPORTING_CONFIG_SCHEMA || typeof config.enabled !== 'boolean') return null;
|
|
154
|
+
return { enabled: config.enabled,
|
|
155
|
+
signer: validReportingSigner(config.signer) ? config.signer : null,
|
|
156
|
+
url: validReportingUrl(config.url) ? config.url : null };
|
|
133
157
|
} catch {
|
|
134
|
-
return
|
|
158
|
+
return null;
|
|
135
159
|
}
|
|
136
160
|
}
|
|
137
161
|
|
|
162
|
+
export function runtimeErrorReportingEnabled(options = {}) {
|
|
163
|
+
return readRuntimeErrorReportingConfig(options)?.enabled === true;
|
|
164
|
+
}
|
|
165
|
+
|
|
138
166
|
function collectionEnabled(options = {}) {
|
|
139
167
|
return factoryCollectionEnabled(options) || runtimeErrorReportingEnabled(options);
|
|
140
168
|
}
|
|
@@ -240,7 +268,7 @@ export function ensureSafeDir(dir) {
|
|
|
240
268
|
|
|
241
269
|
/**
|
|
242
270
|
* `scratchDir`はWindowsだけが使う: DACLの読み取りが出力fileを置くフォルダ。既定はそのfileのフォルダ。
|
|
243
|
-
* storeの外のfile
|
|
271
|
+
* storeの外のfileを確かめる時は、絞ってあるfolderを渡す。
|
|
244
272
|
*/
|
|
245
273
|
export function ensureSafeFile(path, scratchDir = dirname(path)) {
|
|
246
274
|
const stats = lstatSync(path);
|
package/src/todo-cli.mjs
CHANGED
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
readTodoStructureSource,
|
|
83
83
|
todoStructureSourceRef,
|
|
84
84
|
resolveTodoStartRetractionBinding,
|
|
85
|
-
readTodoCarriedBlocks,
|
|
85
|
+
readTodoCarriedBlocks, readTodoTaskAdded,
|
|
86
86
|
readTodoWitnessSet,
|
|
87
87
|
todoWitnessRef,
|
|
88
88
|
writeTodoWitnessSet,
|
|
@@ -171,11 +171,12 @@ import { compileSeamProposalArtifact, declaredConcernSymbols } from './seam-prop
|
|
|
171
171
|
import { collectSensorEvidence } from './sensor-adapter.mjs';
|
|
172
172
|
import { newTodoNotices, projectTodoNotices, waitInEffect, withTodoPriorityWaits } from './todo-notices.mjs';
|
|
173
173
|
import {
|
|
174
|
-
externalCycle, readTodoExternalChart, readTodoExternalTasks, withTodoExternalTasks,
|
|
174
|
+
externalCycle, readTodoExternalChart, readTodoExternalTasks, TODO_CHARTS_ROOT_ENV, withTodoExternalTasks,
|
|
175
175
|
} from './todo-external.mjs';
|
|
176
176
|
import { projectTodoTrees } from './todo-trees.mjs';
|
|
177
177
|
import { closedDisplayHistory, compactDisplayStore, decodeHistoryCursor, openDisplayResult } from './todo-store-view.mjs';
|
|
178
178
|
import { projectTodoBlockers, todoBlockerKey } from './todo-blockers.mjs';
|
|
179
|
+
import { listTodoConnectionWaiters, waitersByTask } from './todo-waiters.mjs';
|
|
179
180
|
import {
|
|
180
181
|
ackTodoNotices, cancelTodoNoticeWait, readAllTodoNoticeAcks, readAllTodoNoticeWaits, readTodoNoticeAcks, writeTodoNoticeWait,
|
|
181
182
|
} from './todo-notice-store.mjs';
|
|
@@ -199,6 +200,7 @@ import {
|
|
|
199
200
|
appendTodoNote,
|
|
200
201
|
readTodoNoteContext,
|
|
201
202
|
readTodoNoteContextsForPlan,
|
|
203
|
+
readTodoNoteSource,
|
|
202
204
|
readTodoNoteEvents,
|
|
203
205
|
readTodoPlanNotesForStatus,
|
|
204
206
|
} from './todo-note-store.mjs';
|
|
@@ -312,7 +314,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
312
314
|
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
313
315
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
314
316
|
'unblock', 'retire', 'done', 'reopen', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
315
|
-
'retract', 'dependency', 'predecessor', 'connect', 'add', 'notice', 'wait', 'blockers', 'compact', 'function-split',
|
|
317
|
+
'retract', 'dependency', 'predecessor', 'connect', 'add', 'notice', 'wait', 'blockers', 'waiters', 'compact', 'function-split',
|
|
316
318
|
]);
|
|
317
319
|
|
|
318
320
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -383,6 +385,7 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
383
385
|
'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
|
|
384
386
|
'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
|
|
385
387
|
blockers: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
|
|
388
|
+
waiters: Object.freeze({ known: ['plan', 'task', 'open', 'json'], required: [], booleans: ['open', 'json'] }),
|
|
386
389
|
compact: Object.freeze({ known: ['plan', 'limit', 'json'], required: [], booleans: ['json'] }),
|
|
387
390
|
'connect priority': Object.freeze({ known: ['plan', 'task', 'reason', 'cancel', 'json'], required: ['plan', 'task'], booleans: ['cancel', 'json'] }),
|
|
388
391
|
wait: Object.freeze({ known: ['plan', 'task', 'reason', 'cancel', 'json'], required: ['plan', 'task'], booleans: ['cancel', 'json'] }),
|
|
@@ -1289,9 +1292,12 @@ async function displayRead(repoRoot, env, { compact = false, open = false } = {}
|
|
|
1289
1292
|
const result = { schema: 'lattice.todo_display_read_result.v1', ...display, external_tasks: externalTasks,
|
|
1290
1293
|
trees: display.store ? projectTodoTrees(display.store) : [],
|
|
1291
1294
|
...(display.store && splitLabels(display.store).length > 0 ? { labels: splitLabels(display.store) } : {}),
|
|
1292
|
-
connections: display.store ? await displayConnections(repoRoot, { ...display.store, external_tasks: externalTasks }) : []
|
|
1295
|
+
connections: display.store ? await displayConnections(repoRoot, { ...display.store, external_tasks: externalTasks }) : [],
|
|
1296
|
+
...(display.store ? await waitersFields(display.store, env, { open }) : {}) };
|
|
1293
1297
|
// trees, labels and connections are read from the full view above; only the shipped store is compacted
|
|
1294
|
-
|
|
1298
|
+
// n3: who added each task (a plan revision, not a journal event), per verified member; a failed read is an empty map.
|
|
1299
|
+
const addedByPlan = compact || open ? await tasksAdded(repoRoot, result.store) : new Map();
|
|
1300
|
+
const light = compact || open ? { ...result, schema: 'lattice.todo_display_compact_result.v1', store: result.store && compactDisplayStore(result.store, { addedByPlan }) } : result;
|
|
1295
1301
|
if (!open) return light;
|
|
1296
1302
|
// next_ready (open v2): `todo status`'s list from this same verified read, so a host needs no second process or Store verification.
|
|
1297
1303
|
const nextReady = display.state === 'verified'
|
|
@@ -1300,6 +1306,16 @@ async function displayRead(repoRoot, env, { compact = false, open = false } = {}
|
|
|
1300
1306
|
return openDisplayResult({ ...light, next_ready: nextReady });
|
|
1301
1307
|
}
|
|
1302
1308
|
|
|
1309
|
+
/** n3: `Map<plan_key, Map<task_id, {at, agent}>>` of the members that have a journal (a raw unverified member has none). */
|
|
1310
|
+
async function tasksAdded(repoRoot, store) {
|
|
1311
|
+
const byPlan = new Map();
|
|
1312
|
+
for (const member of store?.members ?? []) {
|
|
1313
|
+
if (member.journal === undefined) continue;
|
|
1314
|
+
byPlan.set(member.plan.plan_key, await readTodoTaskAdded({ repoRoot, member }).catch(() => new Map()));
|
|
1315
|
+
}
|
|
1316
|
+
return byPlan;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1303
1319
|
const HISTORY_DEFAULT_LIMIT = 50;
|
|
1304
1320
|
const HISTORY_MAX_LIMIT = 500;
|
|
1305
1321
|
|
|
@@ -2217,7 +2233,7 @@ async function connectCondition({ repoRoot, env, operation, planKey, taskId, to,
|
|
|
2217
2233
|
}
|
|
2218
2234
|
}
|
|
2219
2235
|
// Store is idempotent (appendTodoEvent answers `unchanged`), so no pre-check; the newest entry for this ref names the target.
|
|
2220
|
-
const shown = listTodoConnections(store, planKey, taskId
|
|
2236
|
+
const shown = listTodoConnections(store, planKey, taskId)
|
|
2221
2237
|
.filter((entry) => entry.kind === 'schedule' && entry.ref === target.id)
|
|
2222
2238
|
.sort((left, right) => (left.since < right.since ? 1 : left.since > right.since ? -1 : 0))[0] ?? null;
|
|
2223
2239
|
if (operation !== 'add' && shown === null) throw notFound();
|
|
@@ -2876,10 +2892,12 @@ async function todoDetail({ repoRoot, env, planKey, taskId }) {
|
|
|
2876
2892
|
plan_key: planKey,
|
|
2877
2893
|
plan_version: member.plan.plan_version,
|
|
2878
2894
|
// v7以前のtaskは欄を持たないのでnullで投影する(u12)。
|
|
2879
|
-
task: { ...task, done_condition: task.done_condition ?? null
|
|
2895
|
+
task: { ...task, done_condition: task.done_condition ?? null,
|
|
2896
|
+
added: (await readTodoTaskAdded({ repoRoot, member }).catch(() => new Map())).get(task.task_id) ?? null },
|
|
2880
2897
|
design_memo: designMemoProjection(task),
|
|
2881
2898
|
state,
|
|
2882
2899
|
prerequisites: taskPrerequisites(store, member, task.task_id),
|
|
2900
|
+
...await taskWaiters(store, env, planKey, task.task_id),
|
|
2883
2901
|
note_context: context,
|
|
2884
2902
|
...(relations === null ? {} : { relations }),
|
|
2885
2903
|
...(labels.length === 0 ? {} : { labels }),
|
|
@@ -2891,6 +2909,12 @@ async function todoDetail({ repoRoot, env, planKey, taskId }) {
|
|
|
2891
2909
|
return result;
|
|
2892
2910
|
}
|
|
2893
2911
|
|
|
2912
|
+
/** n2: `waiters` (all states) and `waiters_unread` of one task; a failed scan is `waiters: null` + the reason. */
|
|
2913
|
+
async function taskWaiters(store, env, planKey, taskId) {
|
|
2914
|
+
const fields = await waitersFields(store, env, { planKey, taskId });
|
|
2915
|
+
return fields.waiters == null ? fields : { ...fields, waiters: fields.waiters[0]?.waiters ?? [] };
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2894
2918
|
/** xchart: what a task waits on, by the readiness predicate (`ready` is the start path's own answer). */
|
|
2895
2919
|
function taskPrerequisites(store, member, taskId) {
|
|
2896
2920
|
const readiness = createTodoReadiness(store);
|
|
@@ -2912,11 +2936,16 @@ async function appendNote({ repoRoot, env, planKey, taskId, message, inputRef, s
|
|
|
2912
2936
|
const body = inputRef === null ? message : await readNoteTextInput(repoRoot, inputRef);
|
|
2913
2937
|
// 訂正はscopeを跨げない。plan noteはplan chainの中だけ、task noteは自分のtaskの中だけを
|
|
2914
2938
|
// 訂正できる。contextはplan noteも載せるので、task側はscopeで絞らないと跨げてしまう。
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2939
|
+
// w2: the note chains and the version lineage are read once, before anything is written (a broken history still refuses first),
|
|
2940
|
+
// and the context is projected once, after the append. Only a correction needs the history before it (eligibleSupersedes
|
|
2941
|
+
// is read only when supersedes is set).
|
|
2942
|
+
const source = task === null ? null : await readTodoNoteSource({ repoRoot, store, planKey, taskId: task.task_id });
|
|
2943
|
+
let eligibleSupersedes = [];
|
|
2944
|
+
if (supersedes !== null) {
|
|
2945
|
+
eligibleSupersedes = task === null
|
|
2946
|
+
? (await readTodoNoteEvents({ repoRoot, planKey, scope: 'plan' })).events.map(({ event_digest: digest }) => digest)
|
|
2947
|
+
: source.project().history.filter(({ scope }) => scope === 'task').map(({ event_digest: digest }) => digest);
|
|
2948
|
+
}
|
|
2920
2949
|
const event = await appendTodoNote({
|
|
2921
2950
|
repoRoot,
|
|
2922
2951
|
projectId: store.project_id,
|
|
@@ -2931,8 +2960,7 @@ async function appendNote({ repoRoot, env, planKey, taskId, message, inputRef, s
|
|
|
2931
2960
|
});
|
|
2932
2961
|
// plan noteはどのtaskのcontextにも載るので、1つを選んで返すと嘘になる。全部読むなら
|
|
2933
2962
|
// `note list --plan <k>`。書けたことの証拠はeventそのものが持つ。
|
|
2934
|
-
const context =
|
|
2935
|
-
? null : (await readTodoNoteContext({ repoRoot, store, planKey, taskId: task.task_id })).context;
|
|
2963
|
+
const context = source === null ? null : source.project([event]).context;
|
|
2936
2964
|
const result = {
|
|
2937
2965
|
schema: 'lattice.todo_note_append_result.v2',
|
|
2938
2966
|
project_id: store.project_id,
|
|
@@ -5056,6 +5084,44 @@ async function blockerList({ repoRoot }) {
|
|
|
5056
5084
|
return result;
|
|
5057
5085
|
}
|
|
5058
5086
|
|
|
5087
|
+
/** n2: the waiters of every task of `store` as result fields; a failed scan is named, never "no waiters". */
|
|
5088
|
+
async function waitersFields(store, env, options = {}) {
|
|
5089
|
+
// A single chart (no charts root) has no other chart to wait from: results keep their shape, `todo waiters` answers empty.
|
|
5090
|
+
if (options.always !== true && !(typeof env?.[TODO_CHARTS_ROOT_ENV] === 'string' && env[TODO_CHARTS_ROOT_ENV] !== '')) return {};
|
|
5091
|
+
try {
|
|
5092
|
+
const { waiters, unread } = await listTodoConnectionWaiters(store, env);
|
|
5093
|
+
return { waiters: waitersByTask(waiters, options), waiters_unread: unread };
|
|
5094
|
+
} catch (error) {
|
|
5095
|
+
return { waiters: null, waiters_unavailable: error?.detail?.reason ?? error?.message ?? 'waiters_unreadable' };
|
|
5096
|
+
}
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
/** `todo waiters [--plan <key>] [--task <id>] [--open]`: who waits on tasks of this chart through 接続, from other charts. */
|
|
5100
|
+
async function todoWaiters({ repoRoot, env, planKey = null, taskId = null, open = false }) {
|
|
5101
|
+
const store = await readTodoStoreOrNull(repoRoot);
|
|
5102
|
+
const fields = store === null ? { waiters: [], waiters_unread: [] }
|
|
5103
|
+
: await waitersFields(store, env, { open, planKey, taskId, always: true });
|
|
5104
|
+
const result = { schema: 'lattice.todo_waiters_result.v1', project_id: store?.project_id ?? null,
|
|
5105
|
+
tasks: fields.waiters ?? [], unread: fields.waiters_unread ?? [],
|
|
5106
|
+
...(fields.waiters === null ? { waiters_unavailable: fields.waiters_unavailable } : {}), result_digest: '' };
|
|
5107
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
5108
|
+
return result;
|
|
5109
|
+
}
|
|
5110
|
+
|
|
5111
|
+
/** n2: a done, retire or reopen names who waits on that task (all states), so its writer sees whom the change re-judged. */
|
|
5112
|
+
async function withWaiters(repoRoot, result, env) {
|
|
5113
|
+
if (result === null || typeof result !== 'object' || typeof result.result_digest !== 'string'
|
|
5114
|
+
|| typeof result.plan_key !== 'string' || typeof result.task_id !== 'string') return result;
|
|
5115
|
+
const store = await readTodoStoreOrNull(repoRoot);
|
|
5116
|
+
const fields = store === null ? { waiters: null, waiters_unavailable: 'store_missing' }
|
|
5117
|
+
: await waitersFields(store, env, { planKey: result.plan_key, taskId: result.task_id });
|
|
5118
|
+
if (!('waiters' in fields)) return result;
|
|
5119
|
+
const carried = { ...result, ...fields, waiters: fields.waiters === null ? null : (fields.waiters[0]?.waiters ?? []),
|
|
5120
|
+
result_digest: '' };
|
|
5121
|
+
carried.result_digest = todoSelfDigest(carried, 'result_digest');
|
|
5122
|
+
return carried;
|
|
5123
|
+
}
|
|
5124
|
+
|
|
5059
5125
|
/** Open notices with their waiters (wait-design); an unreadable wait file is named, its waits read as none. */
|
|
5060
5126
|
async function openNoticeView(repoRoot, env) {
|
|
5061
5127
|
const store = await readTodoStoreForReadiness({ repoRoot, env });
|
|
@@ -5540,6 +5606,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5540
5606
|
}
|
|
5541
5607
|
} else if (argv[0] === 'blockers' && matchFlagCommand(argv, ['blockers'], TODO_FLAG_SPECS.blockers) !== null) {
|
|
5542
5608
|
action = (repoRoot) => blockerList({ repoRoot });
|
|
5609
|
+
} else if (argv[0] === 'waiters' && matchFlagCommand(argv, ['waiters'], TODO_FLAG_SPECS.waiters) !== null) {
|
|
5610
|
+
const flags = matchFlagCommand(argv, ['waiters'], TODO_FLAG_SPECS.waiters);
|
|
5611
|
+
if ((flags.plan === undefined || isTodoIdentifier(flags.plan)) && (flags.task === undefined || isTodoIdentifier(flags.task))) {
|
|
5612
|
+
action = (repoRoot) => todoWaiters({ repoRoot, env, planKey: flags.plan ?? null, taskId: flags.task ?? null, open: flags.open === true });
|
|
5613
|
+
}
|
|
5543
5614
|
} else if ((argv[0] === 'connect' && argv[1] === 'priority' || argv[0] === 'wait')
|
|
5544
5615
|
&& matchFlagCommand(argv, argv[0] === 'wait' ? ['wait'] : ['connect', 'priority'], TODO_FLAG_SPECS[argv[0] === 'wait' ? 'wait' : 'connect priority']) !== null) {
|
|
5545
5616
|
const flags = matchFlagCommand(argv, argv[0] === 'wait' ? ['wait'] : ['connect', 'priority'], TODO_FLAG_SPECS[argv[0] === 'wait' ? 'wait' : 'connect priority']);
|
|
@@ -5949,7 +6020,8 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5949
6020
|
const written = atomicCommit
|
|
5950
6021
|
? await commitTodoStoreMutation({ repoRoot, argv, action, env })
|
|
5951
6022
|
: await action(repoRoot);
|
|
5952
|
-
const
|
|
6023
|
+
const noticed = releasesTasks(argv) ? await withNotices(repoRoot, written, before, env) : written;
|
|
6024
|
+
const result = ['done', 'retire', 'reopen'].includes(argv[0]) ? await withWaiters(repoRoot, noticed, env) : noticed;
|
|
5953
6025
|
if (result !== null) stdout.write(`${plainVerify ? verifyVerdictLine(result) : JSON.stringify(result)}\n`);
|
|
5954
6026
|
if (!atomicCommit && revisesPlan(argv)) await carryIndependenceAfterRevision({ cwd });
|
|
5955
6027
|
if (!atomicCommit && ['done', 'retire'].includes(argv[0]) && typeof result?.plan_key === 'string') {
|
package/src/todo-external.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
|
|
7
7
|
import { createTodoReadiness } from './todo-readiness.mjs';
|
|
8
|
-
import { isFinishedTodoTaskState, projectTodoCrossPlanDependencies } from './todo-store-view.mjs';
|
|
8
|
+
import { isFinishedTodoTaskState, projectTodoCrossPlanDependencies, todoTaskContentDigest } from './todo-store-view.mjs';
|
|
9
9
|
import { readTodoStoreReadOnly, TodoStoreError } from './todo-store.mjs';
|
|
10
10
|
|
|
11
11
|
export const TODO_CHARTS_ROOT_ENV = 'LATTICE_CHARTS_ROOT';
|
|
@@ -72,6 +72,7 @@ export async function readTodoExternalTasks(store, env) {
|
|
|
72
72
|
const chart = charts.get(from.project_id);
|
|
73
73
|
const member = chart.store?.members.find(({ plan }) => plan.plan_key === from.plan_key);
|
|
74
74
|
const state = member?.tasks.find(({ task_id: id }) => id === from.task_id);
|
|
75
|
+
const planTask = member?.plan.tasks?.find(({ task_id: id }) => id === from.task_id);
|
|
75
76
|
const reason = chart.store === undefined ? chart.reason : state === undefined ? 'endpoint_missing' : null;
|
|
76
77
|
if (reason !== null) {
|
|
77
78
|
findings.push({ owner_plan_key: dependency.to.plan_key, event_digest: dependency.event_digest,
|
|
@@ -80,6 +81,10 @@ export async function readTodoExternalTasks(store, env) {
|
|
|
80
81
|
tasks.set(`${from.project_id}\0${from.plan_key}\0${from.task_id}`, {
|
|
81
82
|
project_id: from.project_id, plan_key: from.plan_key, task_id: from.task_id,
|
|
82
83
|
status: state?.status ?? null, finished: isFinishedTodoTaskState(state), reason,
|
|
84
|
+
// n2: a readable chart without the task is gone (never blocks, as in-chart A24); an unreadable chart stays unknown.
|
|
85
|
+
missing: reason === 'endpoint_missing',
|
|
86
|
+
// n2: what a reader sees of the target's content (title, done condition, lane, split); null when unread or missing.
|
|
87
|
+
content_digest: planTask === undefined ? null : todoTaskContentDigest(planTask, member.plan.tasks),
|
|
83
88
|
trigger: state === undefined ? null : taskTrigger(member, from.task_id),
|
|
84
89
|
});
|
|
85
90
|
}
|
|
@@ -52,10 +52,11 @@ const CONNECTION_TARGET = Object.freeze({ task: '工程', schedule: '予定' });
|
|
|
52
52
|
function connectionLine(entry) {
|
|
53
53
|
const label = CONNECTION_LABEL[entry.kind] ?? '接続';
|
|
54
54
|
const settled = entry.state === 'settled';
|
|
55
|
+
const gone = entry.state === 'gone';
|
|
55
56
|
const target = entry.kind === 'priority'
|
|
56
57
|
? `${entry.agent}(着手できるようになったら知らせを受ける)`
|
|
57
58
|
: `${CONNECTION_TARGET[entry.kind] ?? ''} <code>${escapeHtmlText(entry.ref)}</code>`;
|
|
58
|
-
const state = entry.kind === 'priority' ? '' : settled ? ' — 成立' : entry.state_reason === 'chart_not_read' ? ' — 開いている(その工程表を読めません)' : ' — 開いている';
|
|
59
|
+
const state = entry.kind === 'priority' ? '' : settled ? ' — 成立' : gone ? ' — 消えた(完了していません)' : entry.state_reason === 'chart_not_read' ? ' — 開いている(その工程表を読めません)' : ' — 開いている';
|
|
59
60
|
const note = [entry.reason, settled ? entry.evidence : null].filter((text) => typeof text === 'string' && text.length > 0).map(escapeHtmlText).join(' / ');
|
|
60
61
|
return `<li class="connection connection-${escapeHtmlAttribute(entry.kind)}" data-state="${escapeHtmlAttribute(entry.state ?? 'open')}"><strong>${label}</strong> ${target}${state}${note === '' ? '' : ` — ${note}`}${entry.since ? ` <time>${escapeHtmlText(entry.since)}</time>` : ''}</li>`;
|
|
61
62
|
}
|
|
@@ -68,7 +69,7 @@ export function renderConnectionArea(connections = []) {
|
|
|
68
69
|
|
|
69
70
|
/** The chip row: one chip per kind, counting the open 他条件に接続 and the 優先接続. */
|
|
70
71
|
export function renderConnectionChips(connections = []) {
|
|
71
|
-
const open = connections.filter((entry) => entry.kind !== 'priority' && entry.state
|
|
72
|
+
const open = connections.filter((entry) => entry.kind !== 'priority' && (entry.state ?? 'open') === 'open').length;
|
|
72
73
|
const priority = connections.filter((entry) => entry.kind === 'priority').length;
|
|
73
74
|
return `${open === 0 ? '' : `<span class="connection-chip">他条件に接続 ${open}</span>`}${priority === 0 ? '' : '<span class="connection-chip">優先接続</span>'}`;
|
|
74
75
|
}
|