@quolu/lattice 0.89.0 → 0.91.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/package.json +1 -1
- package/src/cli-help.mjs +9 -4
- package/src/todo-cli.mjs +203 -25
- package/src/todo-contracts.mjs +2 -0
- package/src/todo-independence-contracts.mjs +1 -1
- package/src/todo-independence-guidance.mjs +5 -0
- package/src/todo-notice-store.mjs +166 -0
- package/src/todo-notices.mjs +81 -0
- package/src/todo-readiness.mjs +18 -0
- package/src/todo-store-git-transaction.mjs +1 -0
- package/src/todo-store.mjs +40 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.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
|
@@ -87,6 +87,7 @@ Read commands:
|
|
|
87
87
|
status [--json]
|
|
88
88
|
show --plan <key> --task <id> --json # 個別ToDoと最新bounded note contextを追加操作なしで返す
|
|
89
89
|
note list --plan <key> [--task <id>] --json # note全履歴の診断面(通常read/startでは不要)
|
|
90
|
+
notice list [--lane <lane>] [--include-acked] [--json] # 着手できるようになった工程の知らせ(既定は未ackだけ。lane省略で全lane)
|
|
90
91
|
bindings [--plan <key>] [--json] # compile_binding付きTaskをTODO identityつきで投影する
|
|
91
92
|
display read [--json] # host表示用の工程表読取(lattice.todo_display_read_result.v1)。不整合でも断らずstateで返す
|
|
92
93
|
display source [--json] # 安い変更検知(lattice.todo_store_display_source.v1)。変わった時だけreadする
|
|
@@ -101,6 +102,7 @@ Read commands:
|
|
|
101
102
|
phase status --plan <key> [--json]
|
|
102
103
|
|
|
103
104
|
Write commands:
|
|
105
|
+
notice ack --lane <lane> --notice <id>[,<id>...] [--json] # 届けた知らせに印を付ける(閉じた知らせはclosedで返す)
|
|
104
106
|
repair-eol --json # Git checkoutでCRLF化された既存storeをcanonical LFへ戻し、EOL保護を追加する
|
|
105
107
|
dashboard adopt --json # 衝突したproject_idの配信元rootを現在repoへ明示的に移す
|
|
106
108
|
dashboard ensure --json # daemon生存保証の冪等入口(launchd等の周期実行向け)
|
|
@@ -171,8 +173,8 @@ Write commands:
|
|
|
171
173
|
# 実際に受理する最新契約のJSON Schemaを返す(storeを読まない)。
|
|
172
174
|
# 入力が契約に合わないときは、違反フィールドのpathがerror detailへ載る
|
|
173
175
|
phase review --plan <key> --phase <id> --reason <text>
|
|
174
|
-
phase accept --plan <key> --phase <id> --evidence <file> # 監査file
|
|
175
|
-
phase reject --plan <key> --phase <id> --reason <text> --evidence <file>
|
|
176
|
+
phase accept --plan <key> --phase <id> --evidence <file> | --message <text> # 監査file/文から入力を機械が組む
|
|
177
|
+
phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --message <text>
|
|
176
178
|
phase <accept|reject> --plan <key> --phase <id> --input <file>
|
|
177
179
|
phase reopen --plan <key> --phase <id> --reason <text> [--override-reason <text>]
|
|
178
180
|
phase close-unaudited --plan <key> --phase <id> --reason <text>
|
|
@@ -299,6 +301,9 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
299
301
|
'todo show': 'todo show --plan <key> --task <id> --json',
|
|
300
302
|
'todo note': 'todo note --plan <key> [--task <id>] (--message <text>|--input <file>) | list --plan <key> [--task <id>] --json',
|
|
301
303
|
'todo note list': 'todo note list --plan <key> [--task <id>] [--json]',
|
|
304
|
+
'todo notice': 'todo notice list [--lane <lane>] [--include-acked] [--json] | ack --lane <lane> --notice <id>[,<id>...] [--json]',
|
|
305
|
+
'todo notice list': 'todo notice list [--lane <lane>] [--include-acked] [--json] # lattice.todo_notice_list_result.v1',
|
|
306
|
+
'todo notice ack': 'todo notice ack --lane <lane> --notice <id>[,<id>...] [--json] # lattice.todo_notice_ack_result.v1 {acked, already, closed}',
|
|
302
307
|
'todo bindings': 'todo bindings [--plan <key>] [--json]',
|
|
303
308
|
'todo display': 'todo display read [--json] | source [--json] # host表示用の読取。不整合でも断らずstateで返す',
|
|
304
309
|
'todo display read': 'todo display read [--json] # lattice.todo_display_read_result.v1(state: verified|unverified|last_verified|unavailable)',
|
|
@@ -324,8 +329,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
324
329
|
+ ' | baseline --reason <text> [--except <plan_key>]...',
|
|
325
330
|
'todo phase status': 'todo phase status --plan <key> [--json]',
|
|
326
331
|
'todo phase review': 'todo phase review --plan <key> --phase <id> --reason <text>',
|
|
327
|
-
'todo phase accept': 'todo phase accept --plan <key> --phase <id> --evidence <file> | --input <file>',
|
|
328
|
-
'todo phase reject': 'todo phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --input <file>',
|
|
332
|
+
'todo phase accept': 'todo phase accept --plan <key> --phase <id> --evidence <file> | --message <text> | --input <file>',
|
|
333
|
+
'todo phase reject': 'todo phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --message <text> | --input <file>',
|
|
329
334
|
'todo phase reopen': 'todo phase reopen --plan <key> --phase <id> --reason <text> [--override-reason <text>]',
|
|
330
335
|
'todo phase close-unaudited': 'todo phase close-unaudited --plan <key> --phase <id> --reason <text>',
|
|
331
336
|
'todo phase baseline': 'todo phase baseline --reason <text> [--except <plan_key>]...',
|
package/src/todo-cli.mjs
CHANGED
|
@@ -154,6 +154,7 @@ import {
|
|
|
154
154
|
} from './todo-independence.mjs';
|
|
155
155
|
import {
|
|
156
156
|
selectIndependenceGuidance,
|
|
157
|
+
todoIndependenceGuidance,
|
|
157
158
|
selectWitnessScaffoldGuidance,
|
|
158
159
|
selectSeamProposalGuidance,
|
|
159
160
|
scopeExpansionRecommendations,
|
|
@@ -168,6 +169,8 @@ import {
|
|
|
168
169
|
} from './seam-proposal-contracts.mjs';
|
|
169
170
|
import { compileSeamProposalArtifact, declaredConcernSymbols } from './seam-proposal.mjs';
|
|
170
171
|
import { collectSensorEvidence } from './sensor-adapter.mjs';
|
|
172
|
+
import { newTodoNotices, projectTodoNotices } from './todo-notices.mjs';
|
|
173
|
+
import { ackTodoNotices, readAllTodoNoticeAcks, readTodoNoticeAcks } from './todo-notice-store.mjs';
|
|
171
174
|
import { collectTodoIndependenceAuthoritativeObservation } from './todo-independence-authoritative-observation.mjs';
|
|
172
175
|
import { applySeamProposal } from './seam-apply.mjs';
|
|
173
176
|
import { todoPlanPrecedences } from './seam-verification.mjs';
|
|
@@ -302,7 +305,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
|
|
|
302
305
|
'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
|
|
303
306
|
'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
|
|
304
307
|
'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
|
|
305
|
-
'retract', 'dependency', 'add',
|
|
308
|
+
'retract', 'dependency', 'add', 'notice',
|
|
306
309
|
]);
|
|
307
310
|
|
|
308
311
|
function typedArgumentFailure(stderr, code, message, detail, context = {}) {
|
|
@@ -351,8 +354,8 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
351
354
|
split: Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
352
355
|
note: NOTE_FLAG_SPEC,
|
|
353
356
|
// a28: the rest of the writes, and the reads whose --json is optional (their output is JSON either way).
|
|
354
|
-
'phase accept': Object.freeze({ known: ['plan', 'phase', 'evidence', 'input'], required: ['plan', 'phase'] }),
|
|
355
|
-
'phase reject': Object.freeze({ known: ['plan', 'phase', 'evidence', 'reason', 'input'], required: ['plan', 'phase'] }),
|
|
357
|
+
'phase accept': Object.freeze({ known: ['plan', 'phase', 'evidence', 'message', 'input'], required: ['plan', 'phase'] }),
|
|
358
|
+
'phase reject': Object.freeze({ known: ['plan', 'phase', 'evidence', 'message', 'reason', 'input'], required: ['plan', 'phase'] }),
|
|
356
359
|
'phase reopen': Object.freeze({ known: ['plan', 'phase', 'reason', 'override-reason'], required: ['plan', 'phase', 'reason'] }),
|
|
357
360
|
'evidence promote': Object.freeze({ known: ['plan', 'task', 'evidence'], required: ['plan', 'task', 'evidence'] }),
|
|
358
361
|
'independence compile': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
@@ -361,6 +364,8 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
361
364
|
'independence witness declare': Object.freeze({
|
|
362
365
|
known: ['plan', 'task', 'owns', 'reads', 'writes'], required: ['plan', 'task'] }),
|
|
363
366
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
367
|
+
'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
|
|
368
|
+
'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
|
|
364
369
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
365
370
|
'phase status': Object.freeze({ known: ['plan', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
366
371
|
structure: Object.freeze({ known: ['plan', 'json'], required: [], booleans: ['json'] }),
|
|
@@ -484,18 +489,19 @@ function explainArgumentRefusal(argv) {
|
|
|
484
489
|
}
|
|
485
490
|
}
|
|
486
491
|
if (argv[0] === 'phase' && ['accept', 'reject'].includes(argv[1])) {
|
|
487
|
-
const given = ['evidence', 'input'].filter((name) => typeof flags[name] === 'string' && flags[name].length > 0);
|
|
492
|
+
const given = ['evidence', 'message', 'input'].filter((name) => typeof flags[name] === 'string' && flags[name].length > 0);
|
|
488
493
|
if (given.length === 0) {
|
|
489
494
|
return { pointer: '--evidence', rule: 'flag_missing',
|
|
490
|
-
next_action: `Add --evidence <file> (or --input <decision file>): \`${repairedCommand(head, { ...spec, required: [...spec.required, 'evidence', ...(argv[1] === 'reject' ? ['reason'] : [])] }, flags)}\`.` };
|
|
495
|
+
next_action: `Add --evidence <file> (or --message <text>, or --input <decision file>): \`${repairedCommand(head, { ...spec, required: [...spec.required, 'evidence', ...(argv[1] === 'reject' ? ['reason'] : [])] }, flags)}\`.` };
|
|
491
496
|
}
|
|
492
|
-
if (given.length
|
|
493
|
-
|
|
494
|
-
|
|
497
|
+
if (given.length > 1) {
|
|
498
|
+
const [keep, drop] = given;
|
|
499
|
+
return { pointer: `--${drop}`, rule: 'flags_exclusive',
|
|
500
|
+
next_action: `Pass one of --evidence, --message or --input: \`${repairedCommand(head, spec, { ...flags, ...Object.fromEntries(given.filter((name) => name !== keep).map((name) => [name, undefined])) })}\`.` };
|
|
495
501
|
}
|
|
496
|
-
if (argv[1] === 'reject' && given[0]
|
|
502
|
+
if (argv[1] === 'reject' && given[0] !== 'input' && !(typeof flags.reason === 'string' && flags.reason.length > 0)) {
|
|
497
503
|
return { pointer: '--reason', rule: 'flag_missing',
|
|
498
|
-
next_action: `A reject with
|
|
504
|
+
next_action: `A reject with --${given[0]} needs --reason <text>: \`${repairedCommand(head, { ...spec, required: [...spec.required, 'reason'] }, flags)}\`.` };
|
|
499
505
|
}
|
|
500
506
|
if (given[0] === 'input' && flags.reason !== undefined) {
|
|
501
507
|
return { pointer: '--reason', rule: 'flag_unknown',
|
|
@@ -871,8 +877,9 @@ async function readStructureSetDraft(repoRoot, inputRef) {
|
|
|
871
877
|
function auditGateGuidance(planKey, phaseId, auditRequired = false) {
|
|
872
878
|
const target = `--plan ${planKey} --phase ${phaseId}`;
|
|
873
879
|
const audit = `lattice todo phase review ${target} --reason <text> → accept ${target} --evidence <file>`;
|
|
874
|
-
// ADR 0200 gate 5: an enforced plan's heavy phase refuses close-unaudited, so only the audit is offered
|
|
875
|
-
|
|
880
|
+
// ADR 0200 gate 5: an enforced plan's heavy phase refuses close-unaudited, so only the audit is offered,
|
|
881
|
+
// with the --message route for a seat that cannot write a file into the Store root.
|
|
882
|
+
if (auditRequired) return `全ToDoがdone。このplanはenforcedでheavyの段階なので監査する: ${audit}(fileを置けないなら --message <text>)`;
|
|
876
883
|
return `全ToDoがdone。監査せず閉じるなら: lattice todo phase close-unaudited ${target} --reason <text>`
|
|
877
884
|
+ `(監査するなら ${audit})`;
|
|
878
885
|
}
|
|
@@ -1283,6 +1290,20 @@ async function startAdvisory({ repoRoot, store, projection, planKey, taskId }) {
|
|
|
1283
1290
|
// 調整方式の宣言(ob03)。未宣言はnullで、「まだ選んでいない」を意味する。
|
|
1284
1291
|
const coordinationMode = store.members
|
|
1285
1292
|
.find(({ descriptor }) => descriptor.plan_key === planKey)?.coordination?.mode ?? null;
|
|
1293
|
+
if (artifact === null && unusable === null && await declaredWithoutHead({ repoRoot, planKey, taskId })) {
|
|
1294
|
+
// declare-without-git: the row is recorded but a Store root with no commit cannot be observed.
|
|
1295
|
+
// Declared, never "safe": coverage says so and gate 1 lets the declared task start.
|
|
1296
|
+
return {
|
|
1297
|
+
coverage: 'declared_unobserved',
|
|
1298
|
+
drift_intersecting: null,
|
|
1299
|
+
conflicts_with_active: [],
|
|
1300
|
+
scope_expansion_recommendations: [],
|
|
1301
|
+
uncovered_active_task_ids: projection.active_set
|
|
1302
|
+
.filter((task) => task.plan_key === planKey).map(({ task_id: id }) => id),
|
|
1303
|
+
self_unknowns: [{ kind: 'observation_unavailable', ref: 'git_head_unresolved' }],
|
|
1304
|
+
guidance: todoIndependenceGuidance('independence_declared_unobserved', { planKey }),
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1286
1307
|
if (artifact === null) {
|
|
1287
1308
|
// 記録が無ければ鮮度を語る相手がいない。HEADを要求すると、commitがまだ無いrepoで
|
|
1288
1309
|
// 「判定できない」でなく「startできない」になってしまう。
|
|
@@ -1424,6 +1445,23 @@ async function startTask({
|
|
|
1424
1445
|
structureContext, featureContext });
|
|
1425
1446
|
}
|
|
1426
1447
|
|
|
1448
|
+
/** declare-without-git: HEAD does not resolve (no commit) and the plan's witness set records this task's row. */
|
|
1449
|
+
async function declaredWithoutHead({ repoRoot, planKey, taskId }) {
|
|
1450
|
+
if (headResolves(repoRoot)) return false;
|
|
1451
|
+
const recorded = await readTodoWitnessSet({ repoRoot, planKey }).catch(() => null);
|
|
1452
|
+
return recorded?.plan_key === planKey && Object.hasOwn(recorded.manual_witness, taskId);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
function headResolves(repoRoot) {
|
|
1456
|
+
try {
|
|
1457
|
+
currentHeadSha(repoRoot);
|
|
1458
|
+
return true;
|
|
1459
|
+
} catch (error) {
|
|
1460
|
+
if (error?.code === 'INDEPENDENCE_BASE_UNRESOLVED') return false;
|
|
1461
|
+
throw error;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1427
1465
|
const declareCommand = (planKey, taskId) => `lattice todo independence witness declare --plan ${planKey} --task ${taskId}`
|
|
1428
1466
|
+ ' --owns <path>[,<path>...] [--reads <path>,...] [--writes <path>,...]';
|
|
1429
1467
|
|
|
@@ -1549,7 +1587,8 @@ const PHASE_DECISION_EXPECTED = Object.freeze({
|
|
|
1549
1587
|
reject: '{ "schema": "lattice.phase_reject_input.v1", "review_event_digest": "<phase reviewのevent_digest>",'
|
|
1550
1588
|
+ ' "reason": "<text>", "decision_evidence": <evidence記述子>, "input_digest": "" }',
|
|
1551
1589
|
note: 'input_digestは入口が計算する。証拠fileがcommit済みなら、`--evidence <file>`で'
|
|
1552
|
-
+ 'review_event_digest・記述子・必須slotを機械が埋める。
|
|
1590
|
+
+ 'review_event_digest・記述子・必須slotを機械が埋める。fileを置けないなら`--message <text>`でも同じく埋まる'
|
|
1591
|
+
+ '(commitまではuncommitted)。evidence記述子の形はEVIDENCE_DESCRIPTOR_EXPECTEDを見る。',
|
|
1553
1592
|
});
|
|
1554
1593
|
|
|
1555
1594
|
async function phaseDecision({ repoRoot, env, planKey, phaseId, outcome, inputRef }) {
|
|
@@ -1586,7 +1625,9 @@ async function phaseDecision({ repoRoot, env, planKey, phaseId, outcome, inputRe
|
|
|
1586
1625
|
* fileから作る。必須slotが1つならその証拠で埋める。複数slotへ1つの証拠を流用すると
|
|
1587
1626
|
* 「各slotを別々に確かめた」ことを偽るので、その場合は`--input`で明示させる。
|
|
1588
1627
|
*/
|
|
1589
|
-
async function phaseDecisionFromEvidence({
|
|
1628
|
+
async function phaseDecisionFromEvidence({
|
|
1629
|
+
repoRoot, env, planKey, phaseId, outcome, evidenceRef = null, evidenceMessage = null, reason,
|
|
1630
|
+
}) {
|
|
1590
1631
|
const store = await readTodoStore({ repoRoot });
|
|
1591
1632
|
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
1592
1633
|
if (member === undefined) {
|
|
@@ -1613,8 +1654,9 @@ async function phaseDecisionFromEvidence({ repoRoot, env, planKey, phaseId, outc
|
|
|
1613
1654
|
next_action: `lattice todo phase accept --plan ${planKey} --phase ${phaseId} --input <file>`,
|
|
1614
1655
|
});
|
|
1615
1656
|
}
|
|
1657
|
+
// A --message becomes message evidence exactly as in `todo done`: no file inside the Store root is needed.
|
|
1616
1658
|
const evidence = await resolveDoneEvidence({
|
|
1617
|
-
repoRoot, evidenceRef, evidenceMessage
|
|
1659
|
+
repoRoot, evidenceRef, evidenceMessage, planKey, taskId: `${phaseId}-${outcome}`,
|
|
1618
1660
|
});
|
|
1619
1661
|
const payload = outcome === 'accept'
|
|
1620
1662
|
? { review_event_digest: state.review_event_digest, decision_evidence: evidence,
|
|
@@ -1623,6 +1665,12 @@ async function phaseDecisionFromEvidence({ repoRoot, env, planKey, phaseId, outc
|
|
|
1623
1665
|
return phaseMutation({ repoRoot, env, planKey, phaseId, kind: `phase_${outcome}`, payload });
|
|
1624
1666
|
}
|
|
1625
1667
|
|
|
1668
|
+
/** A phase decision's evidence: committed, uncommitted (no ref reaches it yet, e.g. `--message` on a root with no commit) or null. */
|
|
1669
|
+
function decisionEvidenceState(repoRoot, store, evidence) {
|
|
1670
|
+
if (evidence === null || evidence === undefined) return null;
|
|
1671
|
+
return isTodoEvidenceUncommitted({ repoRoot, store, evidence }) ? 'uncommitted' : 'committed';
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1626
1674
|
async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload }) {
|
|
1627
1675
|
if (kind === 'phase_close_unaudited') {
|
|
1628
1676
|
// ADR 0200 gate 5: an enforced plan keeps the audit its author required for a heavy phase.
|
|
@@ -1632,7 +1680,8 @@ async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload })
|
|
|
1632
1680
|
if (phaseAuditRequired(member, phase?.gate_policy)) {
|
|
1633
1681
|
throw new TodoStoreError('TODO_TRANSITION_REFUSED', 'enforced_heavy_phase_unaudited', undefined, {
|
|
1634
1682
|
plan_key: planKey, phase_id: phaseId,
|
|
1635
|
-
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
|
|
1683
|
+
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>\``
|
|
1684
|
+
+ ` (or \`--message <text>\` when no file can be written into the Store root);`
|
|
1636
1685
|
+ ' or revise the phase to a non-heavy gate_policy with `lattice plan revise` (recorded).',
|
|
1637
1686
|
});
|
|
1638
1687
|
}
|
|
@@ -1651,7 +1700,10 @@ async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload })
|
|
|
1651
1700
|
plan_key: event.plan_key, plan_version: event.plan_version, phase_id: event.phase_id,
|
|
1652
1701
|
kind: event.kind, sequence: event.sequence, event_digest: event.event_digest,
|
|
1653
1702
|
journal_head_digest: event.event_digest, snapshot_digest: snapshot.snapshot_digest,
|
|
1654
|
-
status: phase.status,
|
|
1703
|
+
status: phase.status,
|
|
1704
|
+
decision_evidence_state: phase.decision_evidence === null || phase.decision_evidence === undefined ? null
|
|
1705
|
+
: decisionEvidenceState(repoRoot, await readTodoStore({ repoRoot }), phase.decision_evidence),
|
|
1706
|
+
result_digest: '',
|
|
1655
1707
|
};
|
|
1656
1708
|
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
1657
1709
|
return result;
|
|
@@ -1981,6 +2033,7 @@ async function phaseStatus({ repoRoot, planKey }) {
|
|
|
1981
2033
|
// v4/v5の実Phaseがgate_readyになった場合も同じ理由で同じ案内が要る。
|
|
1982
2034
|
const phases = member.phases.map((phase) => ({
|
|
1983
2035
|
...phase,
|
|
2036
|
+
decision_evidence_state: decisionEvidenceState(repoRoot, store, phase.decision_evidence),
|
|
1984
2037
|
acceptance_stale: phaseAcceptanceStale(member.plan, member.journal.events, phase, member.tasks),
|
|
1985
2038
|
guidance: phaseAcceptanceStale(member.plan, member.journal.events, phase, member.tasks)
|
|
1986
2039
|
? staleAcceptanceGuidance(member.plan.plan_key, phase.phase_id)
|
|
@@ -3820,13 +3873,22 @@ async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
|
3820
3873
|
const waitingFor = projectTodoStatus(await readTodoStore({ repoRoot }), TODO_STATUS_DISPATCH_ONLY).next_ready
|
|
3821
3874
|
.filter((task) => task.plan_key === planKey && !keep.has(task.task_id))
|
|
3822
3875
|
.map(({ task_id: id }) => id).sort();
|
|
3823
|
-
|
|
3876
|
+
// declare-without-git: a Store root with no commit cannot be observed, so the row is recorded and not compiled.
|
|
3877
|
+
const observable = headResolves(repoRoot);
|
|
3878
|
+
const compile = waitingFor.length === 0 && observable
|
|
3824
3879
|
? await independenceCompile({ repoRoot, planKey, inputRef: scaffolded.witness_ref }) : null;
|
|
3825
3880
|
const result = {
|
|
3826
3881
|
schema: 'lattice.todo_witness_declare_result.v1', project_id: member.plan.project_id, plan_key: planKey,
|
|
3827
3882
|
task_id: taskId, ...row, witness_ref: scaffolded.witness_ref,
|
|
3828
3883
|
witness_set_digest: scaffolded.witness_set_digest, compiled: compile !== null, waiting_for: waitingFor,
|
|
3829
|
-
compile,
|
|
3884
|
+
compile,
|
|
3885
|
+
...(observable ? {} : {
|
|
3886
|
+
observation: 'unavailable',
|
|
3887
|
+
next_action: `The Store root has no commit (git HEAD unresolved), so ${taskId}'s row is recorded but not observed or compiled:`
|
|
3888
|
+
+ ' coverage reads declared_unobserved (not judged safe). The declared task can start:'
|
|
3889
|
+
+ ` \`lattice todo start --plan ${planKey} --task ${taskId}\`.`,
|
|
3890
|
+
}),
|
|
3891
|
+
result_digest: '',
|
|
3830
3892
|
};
|
|
3831
3893
|
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
3832
3894
|
return result;
|
|
@@ -4544,6 +4606,94 @@ function writesTodoStore(argv) {
|
|
|
4544
4606
|
}
|
|
4545
4607
|
}
|
|
4546
4608
|
|
|
4609
|
+
/** notice-impl: the writes that can make a task startable carry `notices` ([startable notices](dfd-done-notice.md)). */
|
|
4610
|
+
function releasesTasks(argv) {
|
|
4611
|
+
const [command, second] = argv;
|
|
4612
|
+
return ['done', 'retire', 'unblock'].includes(command)
|
|
4613
|
+
|| (command === 'phase' && ['accept', 'close-unaudited'].includes(second))
|
|
4614
|
+
|| (command === 'dependency' && second === 'disconnect');
|
|
4615
|
+
}
|
|
4616
|
+
|
|
4617
|
+
async function openNotices(repoRoot) {
|
|
4618
|
+
const store = await readTodoStore({ repoRoot });
|
|
4619
|
+
const rows = new Map();
|
|
4620
|
+
for (const member of store.members) {
|
|
4621
|
+
if (member.coordination?.mode !== 'enforced') continue;
|
|
4622
|
+
const recorded = await readTodoWitnessSet({ repoRoot, planKey: member.plan.plan_key }).catch(() => null);
|
|
4623
|
+
rows.set(member.plan.plan_key, new Set(Object.keys(recorded?.manual_witness ?? {})));
|
|
4624
|
+
}
|
|
4625
|
+
return projectTodoNotices(store, { declared: (planKey, taskId) => rows.get(planKey)?.has(taskId) === true });
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
/** A committed write is never undone for its notices: an unreadable projection says so and `notice list` recovers. */
|
|
4629
|
+
async function withNotices(repoRoot, result, before) {
|
|
4630
|
+
if (result === null || typeof result !== 'object' || typeof result.result_digest !== 'string') return result;
|
|
4631
|
+
let extra;
|
|
4632
|
+
try {
|
|
4633
|
+
if (before === null) throw new Error('notices_before_unreadable');
|
|
4634
|
+
extra = { notices: newTodoNotices(before, await openNotices(repoRoot)) };
|
|
4635
|
+
} catch (error) {
|
|
4636
|
+
extra = { notices: null, notices_unavailable: error?.detail?.reason ?? error?.message ?? 'notices_unreadable' };
|
|
4637
|
+
}
|
|
4638
|
+
const carried = { ...result, ...extra, result_digest: '' };
|
|
4639
|
+
carried.result_digest = todoSelfDigest(carried, 'result_digest');
|
|
4640
|
+
return carried;
|
|
4641
|
+
}
|
|
4642
|
+
|
|
4643
|
+
// Same bound as the Store's lane check (1..256 chars, no control characters).
|
|
4644
|
+
const isNoticeLane = (value) => typeof value === 'string' && value.length > 0 && value.length <= 256
|
|
4645
|
+
&& !/[\u0000-\u001f\u007f]/u.test(value);
|
|
4646
|
+
|
|
4647
|
+
function noticeAckRefusal(error, lane) {
|
|
4648
|
+
if (!['STORE_CORRUPT', 'UNSUPPORTED_SCHEMA'].includes(error?.code)) throw error;
|
|
4649
|
+
return { lane_file: error.detail?.ref ?? null, code: error.code, reason: error.detail?.reason ?? error.message };
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
/** `todo notice list`: open notices, unacked unless asked; one unreadable ack file never hides the rest. */
|
|
4653
|
+
async function noticeList({ repoRoot, lane, includeAcked }) {
|
|
4654
|
+
const store = await readTodoStore({ repoRoot });
|
|
4655
|
+
const open = (await openNotices(repoRoot)).filter((notice) => lane === null || notice.lane === lane);
|
|
4656
|
+
const acked = new Map();
|
|
4657
|
+
const ackUnreadable = [];
|
|
4658
|
+
if (lane === null) {
|
|
4659
|
+
const all = await readAllTodoNoticeAcks({ repoRoot });
|
|
4660
|
+
for (const record of all.acks) acked.set(record.lane, new Set(record.acks.map(({ notice_id: id }) => id)));
|
|
4661
|
+
ackUnreadable.push(...all.unreadable);
|
|
4662
|
+
} else {
|
|
4663
|
+
try {
|
|
4664
|
+
const record = await readTodoNoticeAcks({ repoRoot, lane });
|
|
4665
|
+
acked.set(lane, new Set((record?.acks ?? []).map(({ notice_id: id }) => id)));
|
|
4666
|
+
} catch (error) {
|
|
4667
|
+
ackUnreadable.push(noticeAckRefusal(error, lane));
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
const notices = open.map((notice) => ({ ...notice, acked: acked.get(notice.lane)?.has(notice.notice_id) === true }))
|
|
4671
|
+
.filter((notice) => includeAcked || !notice.acked);
|
|
4672
|
+
const result = {
|
|
4673
|
+
schema: 'lattice.todo_notice_list_result.v1', project_id: store.project_id, lane, notices,
|
|
4674
|
+
ack_unreadable: ackUnreadable, result_digest: '',
|
|
4675
|
+
};
|
|
4676
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4677
|
+
return result;
|
|
4678
|
+
}
|
|
4679
|
+
|
|
4680
|
+
/** `todo notice ack`: an id that is no longer open is reported as closed, never refused (nothing is left to ack). */
|
|
4681
|
+
async function noticeAck({ repoRoot, env, lane, ids }) {
|
|
4682
|
+
const store = await readTodoStore({ repoRoot });
|
|
4683
|
+
const openIds = (await openNotices(repoRoot)).filter((notice) => notice.lane === lane).map(({ notice_id: id }) => id);
|
|
4684
|
+
const open = new Set(openIds);
|
|
4685
|
+
const live = ids.filter((id) => open.has(id));
|
|
4686
|
+
const written = live.length === 0 ? { acked: [], already: [] } : await ackTodoNotices({
|
|
4687
|
+
repoRoot, lane, noticeIds: live, openIds, actor: resolveTodoActor(env), now: new Date().toISOString(),
|
|
4688
|
+
});
|
|
4689
|
+
const result = {
|
|
4690
|
+
schema: 'lattice.todo_notice_ack_result.v1', project_id: store.project_id, lane,
|
|
4691
|
+
acked: written.acked, already: written.already, closed: ids.filter((id) => !open.has(id)).sort(), result_digest: '',
|
|
4692
|
+
};
|
|
4693
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
4694
|
+
return result;
|
|
4695
|
+
}
|
|
4696
|
+
|
|
4547
4697
|
async function ensureActiveProjectDashboard({ repoRoot, env, stderr, strict = false }) {
|
|
4548
4698
|
if (env.LATTICE_DASHBOARD_AUTOSTART === '0') return null;
|
|
4549
4699
|
let actor;
|
|
@@ -4594,6 +4744,11 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
4594
4744
|
uncommittedEvidence.push({ plan_key: planKey, task_id: taskId, repo_id: evidence.repo_id, path: evidence.path,
|
|
4595
4745
|
next_action: `Commit ${evidence.path} (repository ${evidence.repo_id}), then rerun \`lattice todo verify --json\`.` });
|
|
4596
4746
|
}
|
|
4747
|
+
for (const { phase_id: phaseId, decision_evidence: evidence } of member.phases) {
|
|
4748
|
+
if (decisionEvidenceState(repoRoot, store, evidence) !== 'uncommitted') continue;
|
|
4749
|
+
uncommittedEvidence.push({ plan_key: planKey, phase_id: phaseId, repo_id: evidence.repo_id, path: evidence.path,
|
|
4750
|
+
next_action: `Commit ${evidence.path} (repository ${evidence.repo_id}), then rerun \`lattice todo verify --json\`.` });
|
|
4751
|
+
}
|
|
4597
4752
|
const unverified = member.tasks.find((task) => task.evidence_unverified && !pending.includes(task));
|
|
4598
4753
|
if (unverified !== undefined) {
|
|
4599
4754
|
throw new TodoStoreError('STORE_INCONSISTENT', 'evidence_unverified', 'evidence_unverified', {
|
|
@@ -4851,6 +5006,19 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4851
5006
|
supersedes: flags.supersedes ?? null,
|
|
4852
5007
|
});
|
|
4853
5008
|
}
|
|
5009
|
+
} else if (argv[0] === 'notice' && argv[1] === 'list'
|
|
5010
|
+
&& matchFlagCommand(argv, ['notice', 'list'], TODO_FLAG_SPECS['notice list']) !== null) {
|
|
5011
|
+
const flags = matchFlagCommand(argv, ['notice', 'list'], TODO_FLAG_SPECS['notice list']);
|
|
5012
|
+
if (flags.lane === undefined || isNoticeLane(flags.lane)) {
|
|
5013
|
+
action = (repoRoot) => noticeList({ repoRoot, lane: flags.lane ?? null, includeAcked: flags['include-acked'] === true });
|
|
5014
|
+
}
|
|
5015
|
+
} else if (argv[0] === 'notice' && argv[1] === 'ack'
|
|
5016
|
+
&& matchFlagCommand(argv, ['notice', 'ack'], TODO_FLAG_SPECS['notice ack']) !== null) {
|
|
5017
|
+
const flags = matchFlagCommand(argv, ['notice', 'ack'], TODO_FLAG_SPECS['notice ack']);
|
|
5018
|
+
const ids = typeof flags.notice === 'string' ? [...new Set(flags.notice.split(',').map((id) => id.trim()))] : [];
|
|
5019
|
+
if (isNoticeLane(flags.lane) && ids.length > 0 && ids.every((id) => /^[0-9a-f]{64}$/u.test(id))) {
|
|
5020
|
+
action = (repoRoot) => noticeAck({ repoRoot, env, lane: flags.lane, ids });
|
|
5021
|
+
}
|
|
4854
5022
|
} else if (argv[0] === 'note' && argv[1] === 'list' && readFlags(argv, ['note', 'list']) !== null) {
|
|
4855
5023
|
const flags = readFlags(argv, ['note', 'list']);
|
|
4856
5024
|
action = (repoRoot) => listNotes({ repoRoot, planKey: flags.plan, taskId: flags.task ?? null });
|
|
@@ -5058,21 +5226,29 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5058
5226
|
} else if (argv[0] === 'phase' && ['accept', 'reject'].includes(argv[1])) {
|
|
5059
5227
|
const outcome = argv[1];
|
|
5060
5228
|
const flags = matchFlagCommand(argv, ['phase', outcome], {
|
|
5061
|
-
known: ['plan', 'phase', 'input', 'evidence', 'reason'], required: ['plan', 'phase'],
|
|
5229
|
+
known: ['plan', 'phase', 'input', 'evidence', 'message', 'reason'], required: ['plan', 'phase'],
|
|
5062
5230
|
});
|
|
5231
|
+
const reasonFits = outcome === 'accept' ? flags?.reason === undefined
|
|
5232
|
+
: typeof flags?.reason === 'string' && flags.reason.length > 0;
|
|
5063
5233
|
const base = flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.phase);
|
|
5064
|
-
if (base && isAuthoringPathToken(flags.input) && flags.evidence === undefined && flags.
|
|
5234
|
+
if (base && isAuthoringPathToken(flags.input) && flags.evidence === undefined && flags.message === undefined
|
|
5235
|
+
&& flags.reason === undefined) {
|
|
5065
5236
|
action = (repoRoot) => phaseDecision({
|
|
5066
5237
|
repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
|
|
5067
5238
|
outcome, inputRef: flags.input,
|
|
5068
5239
|
});
|
|
5069
|
-
} else if (base && flags.input === undefined &&
|
|
5070
|
-
&& (
|
|
5071
|
-
: typeof flags.reason === 'string' && flags.reason.length > 0)) {
|
|
5240
|
+
} else if (base && flags.input === undefined && flags.message === undefined
|
|
5241
|
+
&& isAuthoringPathToken(flags.evidence) && reasonFits) {
|
|
5072
5242
|
action = (repoRoot) => phaseDecisionFromEvidence({
|
|
5073
5243
|
repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
|
|
5074
5244
|
outcome, evidenceRef: flags.evidence, reason: flags.reason ?? null,
|
|
5075
5245
|
});
|
|
5246
|
+
} else if (base && flags.input === undefined && flags.evidence === undefined
|
|
5247
|
+
&& typeof flags.message === 'string' && flags.message.length > 0 && reasonFits) {
|
|
5248
|
+
action = (repoRoot) => phaseDecisionFromEvidence({
|
|
5249
|
+
repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
|
|
5250
|
+
outcome, evidenceMessage: flags.message, reason: flags.reason ?? null,
|
|
5251
|
+
});
|
|
5076
5252
|
}
|
|
5077
5253
|
} else if (argv[0] === 'phase' && argv[1] === 'reopen' && phaseReopenFlags(argv) !== null) {
|
|
5078
5254
|
const flags = phaseReopenFlags(argv);
|
|
@@ -5221,9 +5397,11 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5221
5397
|
if (writesTodoStore(argv)) {
|
|
5222
5398
|
await ensureActiveProjectDashboard({ repoRoot, env, stderr });
|
|
5223
5399
|
}
|
|
5224
|
-
const
|
|
5400
|
+
const before = releasesTasks(argv) ? await openNotices(repoRoot).catch(() => null) : null;
|
|
5401
|
+
const written = atomicCommit
|
|
5225
5402
|
? await commitTodoStoreMutation({ repoRoot, argv, action, env })
|
|
5226
5403
|
: await action(repoRoot);
|
|
5404
|
+
const result = releasesTasks(argv) ? await withNotices(repoRoot, written, before) : written;
|
|
5227
5405
|
if (result !== null) stdout.write(`${plainVerify ? verifyVerdictLine(result) : JSON.stringify(result)}\n`);
|
|
5228
5406
|
return 0;
|
|
5229
5407
|
} catch (error) {
|
package/src/todo-contracts.mjs
CHANGED
|
@@ -41,6 +41,8 @@ export const TODO_NOTE_EVENT_SCHEMA = 'lattice.todo_note_event.v1';
|
|
|
41
41
|
* task noteの読み書きは1バイトも変わらない。
|
|
42
42
|
*/
|
|
43
43
|
export const TODO_NOTE_EVENT_V2_SCHEMA = 'lattice.todo_note_event.v2';
|
|
44
|
+
// Per-lane startable-notice ack set (host-local; todo-notice-store.mjs).
|
|
45
|
+
export const TODO_NOTICE_ACKS_SCHEMA = 'lattice.todo_notice_acks.v1';
|
|
44
46
|
/**
|
|
45
47
|
* v2でnoteの`scope`とplan noteを載せる。v1のままでは`task_id`が identifier 必須・
|
|
46
48
|
* `full_history_command`が`--task <id>`込みの文字列と完全一致で、どちらもplan noteを表せない。
|
|
@@ -62,7 +62,7 @@ export const TODO_INDEPENDENCE_LEGACY_SCHEMAS = Object.freeze([
|
|
|
62
62
|
export const TODO_INDEPENDENCE_TASK_LIMIT = 256;
|
|
63
63
|
export const TODO_INDEPENDENCE_LIST_LIMIT = 4_096;
|
|
64
64
|
export const TODO_INDEPENDENCE_COVERAGE = Object.freeze([
|
|
65
|
-
'verified', 'stale', 'superseded', 'missing',
|
|
65
|
+
'verified', 'stale', 'superseded', 'missing', 'declared_unobserved',
|
|
66
66
|
]);
|
|
67
67
|
|
|
68
68
|
/** conflictを生んだresourceの種別。切断可能性の導出はこの種別だけを根拠にする。 */
|
|
@@ -28,6 +28,7 @@ export const TODO_INDEPENDENCE_GUIDANCE_CODES = Object.freeze([
|
|
|
28
28
|
'independence_conflict_between_ready',
|
|
29
29
|
'independence_verdicts_absent',
|
|
30
30
|
'independence_verified',
|
|
31
|
+
'independence_declared_unobserved',
|
|
31
32
|
]);
|
|
32
33
|
|
|
33
34
|
export const SEAM_PROPOSAL_GUIDANCE_CODES = Object.freeze([
|
|
@@ -113,6 +114,10 @@ const CATALOG = Object.freeze({
|
|
|
113
114
|
message: '判定が途中で止まっており、記録はどの組についてもverdictを持たない。自分にunknownが無いことは、他と干渉しない証拠にならない。',
|
|
114
115
|
next_action: 'lattice todo independence compile --plan <key> --input <file>',
|
|
115
116
|
}),
|
|
117
|
+
independence_declared_unobserved: Object.freeze({
|
|
118
|
+
message: '宣言は記録したが、Storeのrepoにcommitが無いので、触るファイルの観測と並列可否の判定はしていない。干渉しない証拠ではない。',
|
|
119
|
+
next_action: 'none',
|
|
120
|
+
}),
|
|
116
121
|
independence_verified: Object.freeze({
|
|
117
122
|
message: '記録時点の宣言境界では、他のready工程と干渉しない。',
|
|
118
123
|
next_action: 'none',
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstat, mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { LOCK_WAIT_MS, StoreLockError, withStoreLock } from './store-lock.mjs';
|
|
6
|
+
import {
|
|
7
|
+
TODO_LIMITS, TODO_NOTICE_ACKS_SCHEMA, canonicalizeTodoArtifact, exactRecord, isStrictTodoTimestamp, isTodoDigest, isTodoIdentifier,
|
|
8
|
+
todoSelfDigest,
|
|
9
|
+
} from './todo-contracts.mjs';
|
|
10
|
+
import { TodoStoreError, atomicWrite, rejectNewerTodoSchema } from './todo-store.mjs';
|
|
11
|
+
|
|
12
|
+
export { TODO_NOTICE_ACKS_SCHEMA };
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Per-lane ack set of startable notices (dfd-done-notice.md, row "Store: ack set").
|
|
16
|
+
* Host-local delivery state, not a plan fact: it is git-ignored (its own .gitignore), has its own lock, and never touches the
|
|
17
|
+
* lifecycle journals. Losing it means a notice is delivered again, never lost.
|
|
18
|
+
*/
|
|
19
|
+
export const TODO_NOTICE_ROOT_REF = '.lattice/todo/notices';
|
|
20
|
+
const LANE_FILE = /^[0-9a-f]{16}\.json$/u;
|
|
21
|
+
|
|
22
|
+
const fail = (code, reason, detail) => { throw new TodoStoreError(code, reason, reason, detail); };
|
|
23
|
+
const canonicalLine = (value) => `${canonicalizeTodoArtifact(value)}\n`;
|
|
24
|
+
// Lane is the exact string the plan records (bot id or name); bounded so the record stays bounded.
|
|
25
|
+
const isLane = (value) => typeof value === 'string' && value.length > 0 && value.length <= 256
|
|
26
|
+
&& !/\p{Cc}/u.test(value);
|
|
27
|
+
const isActor = (value) => exactRecord(value, ['host', 'session', 'agent'])
|
|
28
|
+
&& [value.host, value.session, value.agent].every(isTodoIdentifier);
|
|
29
|
+
const isAck = (value) => exactRecord(value, ['notice_id', 'acked_at', 'actor'])
|
|
30
|
+
&& isTodoDigest(value.notice_id) && isStrictTodoTimestamp(value.acked_at) && isActor(value.actor);
|
|
31
|
+
const sortedUnique = (ids) => ids.every((id, index) => index === 0 || ids[index - 1] < id);
|
|
32
|
+
|
|
33
|
+
const laneFileName = (lane) => `${createHash('sha256').update(lane, 'utf8').digest('hex').slice(0, 16)}.json`;
|
|
34
|
+
const laneRef = (lane) => path.posix.join(TODO_NOTICE_ROOT_REF, laneFileName(lane));
|
|
35
|
+
|
|
36
|
+
function sealed(lane, acks) {
|
|
37
|
+
const record = { schema: TODO_NOTICE_ACKS_SCHEMA, lane, acks, acks_digest: '' };
|
|
38
|
+
record.acks_digest = todoSelfDigest(record, 'acks_digest');
|
|
39
|
+
return record;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Every refusal names the lane file, so one bad lane never hides another.
|
|
43
|
+
async function readLaneFile(repoRoot, ref) {
|
|
44
|
+
const corrupt = (reason) => fail('STORE_CORRUPT', reason, {
|
|
45
|
+
ref,
|
|
46
|
+
next_action: `${ref} is a host-local notice ack set, not plan data. Delete it to start the lane's acks over`
|
|
47
|
+
+ ' (its open notices are listed and delivered again), or run `lattice todo notice ack` to replace it.',
|
|
48
|
+
});
|
|
49
|
+
let bytes;
|
|
50
|
+
try {
|
|
51
|
+
const state = await lstat(path.resolve(repoRoot, ref));
|
|
52
|
+
if (!state.isFile()) corrupt('notice_acks_not_file');
|
|
53
|
+
if (state.size > TODO_LIMITS.journalSegmentBytes) corrupt('notice_acks_too_large');
|
|
54
|
+
bytes = await readFile(path.resolve(repoRoot, ref), 'utf8');
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof TodoStoreError) throw error;
|
|
57
|
+
if (error?.code === 'ENOENT') return null;
|
|
58
|
+
corrupt('notice_acks_unreadable');
|
|
59
|
+
}
|
|
60
|
+
let record;
|
|
61
|
+
try { record = JSON.parse(bytes); } catch { corrupt('notice_acks_json_invalid'); }
|
|
62
|
+
rejectNewerTodoSchema(record, 'todo_notice_acks', ref);
|
|
63
|
+
if (!exactRecord(record, ['schema', 'lane', 'acks', 'acks_digest']) || record.schema !== TODO_NOTICE_ACKS_SCHEMA
|
|
64
|
+
|| !isLane(record.lane) || !Array.isArray(record.acks) || !record.acks.every(isAck)
|
|
65
|
+
|| !sortedUnique(record.acks.map(({ notice_id: id }) => id)) || !isTodoDigest(record.acks_digest)) {
|
|
66
|
+
corrupt('notice_acks_shape_invalid');
|
|
67
|
+
}
|
|
68
|
+
if (canonicalLine(record) !== bytes) corrupt('notice_acks_not_canonical');
|
|
69
|
+
if (record.acks_digest !== todoSelfDigest(record, 'acks_digest')) corrupt('notice_acks_digest_mismatch');
|
|
70
|
+
if (laneRef(record.lane) !== ref) corrupt('notice_acks_lane_mismatch');
|
|
71
|
+
return record;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The lane's ack set, or null when the lane has none. */
|
|
75
|
+
export async function readTodoNoticeAcks({ repoRoot, lane } = {}) {
|
|
76
|
+
if (typeof repoRoot !== 'string' || !isLane(lane)) throw new TypeError('readTodoNoticeAcks options invalid');
|
|
77
|
+
const ref = laneRef(lane);
|
|
78
|
+
const record = await readLaneFile(path.resolve(repoRoot), ref);
|
|
79
|
+
// A different lane whose hash prefix collides is not this lane's record.
|
|
80
|
+
if (record !== null && record.lane !== lane) {
|
|
81
|
+
fail('STORE_CORRUPT', 'notice_acks_lane_mismatch', { ref, lane, recorded_lane: record.lane });
|
|
82
|
+
}
|
|
83
|
+
return record;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Every lane's ack set; an unreadable lane file is named in `unreadable` and never hides the others. */
|
|
87
|
+
export async function readAllTodoNoticeAcks({ repoRoot } = {}) {
|
|
88
|
+
if (typeof repoRoot !== 'string') throw new TypeError('readAllTodoNoticeAcks options invalid');
|
|
89
|
+
const root = path.resolve(repoRoot);
|
|
90
|
+
let names;
|
|
91
|
+
try { names = (await readdir(path.resolve(root, TODO_NOTICE_ROOT_REF))).filter((name) => LANE_FILE.test(name)).sort(); }
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error?.code === 'ENOENT') return { acks: [], unreadable: [] };
|
|
94
|
+
return { acks: [], unreadable: [{ lane_file: TODO_NOTICE_ROOT_REF, code: 'STORE_CORRUPT', reason: 'notice_acks_unreadable' }] };
|
|
95
|
+
}
|
|
96
|
+
const acks = [];
|
|
97
|
+
const unreadable = [];
|
|
98
|
+
for (const name of names) {
|
|
99
|
+
const ref = path.posix.join(TODO_NOTICE_ROOT_REF, name);
|
|
100
|
+
try {
|
|
101
|
+
const record = await readLaneFile(root, ref);
|
|
102
|
+
if (record !== null) acks.push(record);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (!(error instanceof TodoStoreError)) throw error;
|
|
105
|
+
unreadable.push({ lane_file: ref, code: error.code, reason: error.detail.reason });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { acks, unreadable };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Record acks for `noticeIds` (each must be in `openIds`, the lane's open notices Plan read) and drop
|
|
113
|
+
* acks whose notice is no longer open, so the set stays bounded by the open notices.
|
|
114
|
+
* An unreadable older file is replaced (its acks were already unusable: list shows them unacked);
|
|
115
|
+
* a newer Lattice's file is refused, never downgraded.
|
|
116
|
+
*/
|
|
117
|
+
export async function ackTodoNotices({ repoRoot, lane, noticeIds, openIds, actor, now } = {}) {
|
|
118
|
+
if (typeof repoRoot !== 'string' || !isLane(lane) || !Array.isArray(noticeIds) || noticeIds.length === 0
|
|
119
|
+
|| !Array.isArray(openIds) || ![...noticeIds, ...openIds].every(isTodoDigest)
|
|
120
|
+
|| !isActor(actor) || !isStrictTodoTimestamp(now)) {
|
|
121
|
+
throw new TypeError('ackTodoNotices options invalid');
|
|
122
|
+
}
|
|
123
|
+
const open = new Set(openIds);
|
|
124
|
+
if (!noticeIds.every((id) => open.has(id))) throw new TypeError('ackTodoNotices noticeIds must be open notices');
|
|
125
|
+
const root = path.resolve(repoRoot);
|
|
126
|
+
const directory = path.resolve(root, TODO_NOTICE_ROOT_REF);
|
|
127
|
+
try { await mkdir(directory); }
|
|
128
|
+
catch (error) {
|
|
129
|
+
// Protects against creating a Store skeleton outside a published Store; leaves once the Store exists.
|
|
130
|
+
if (error?.code === 'ENOENT') {
|
|
131
|
+
fail('STORE_WRITE_CONFLICT', 'store_missing', { next_action: 'Initialize the Todo Store, then retry the ack.' });
|
|
132
|
+
}
|
|
133
|
+
if (error?.code !== 'EEXIST') throw error;
|
|
134
|
+
}
|
|
135
|
+
const ref = laneRef(lane);
|
|
136
|
+
try {
|
|
137
|
+
return await withStoreLock({ lockPath: path.join(directory, '.write.lock'), createParent: false, waitMs: LOCK_WAIT_MS },
|
|
138
|
+
async () => {
|
|
139
|
+
// Ignored in any repository, not only where the host's .gitignore says so.
|
|
140
|
+
await writeFile(path.join(directory, '.gitignore'), '*\n', { flag: 'wx' }).catch((error) => {
|
|
141
|
+
if (error?.code !== 'EEXIST') throw error;
|
|
142
|
+
});
|
|
143
|
+
let current = null;
|
|
144
|
+
try { current = await readLaneFile(root, ref); }
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (!(error instanceof TodoStoreError) || error.code !== 'STORE_CORRUPT') throw error;
|
|
147
|
+
}
|
|
148
|
+
// A colliding lane's record is not ours to keep; it is replaced like any unreadable file.
|
|
149
|
+
const kept = (current?.lane === lane ? current.acks : []).filter(({ notice_id: id }) => open.has(id));
|
|
150
|
+
const keptIds = new Set(kept.map(({ notice_id: id }) => id));
|
|
151
|
+
const requested = [...new Set(noticeIds)].sort();
|
|
152
|
+
const already = requested.filter((id) => keptIds.has(id));
|
|
153
|
+
const acked = requested.filter((id) => !keptIds.has(id));
|
|
154
|
+
const acks = [...kept, ...acked.map((id) => ({ notice_id: id, acked_at: now, actor }))]
|
|
155
|
+
.sort((left, right) => (left.notice_id < right.notice_id ? -1 : 1));
|
|
156
|
+
const next = sealed(lane, acks);
|
|
157
|
+
if (current === null || next.acks_digest !== current.acks_digest) {
|
|
158
|
+
await atomicWrite(path.resolve(root, ref), Buffer.from(canonicalLine(next), 'utf8'));
|
|
159
|
+
}
|
|
160
|
+
return { acked, already };
|
|
161
|
+
});
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (error instanceof StoreLockError) fail('STORE_WRITE_CONFLICT', error.reason, error.detail);
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Startable notices (notice-impl, docs/architecture/dfd-done-notice.md): a read-only projection over the
|
|
2
|
+
// Store journals. Lattice records and shows; a notice starts nothing and gates nothing.
|
|
3
|
+
|
|
4
|
+
import { digestTodoArtifact } from './todo-contracts.mjs';
|
|
5
|
+
import { createTodoReadiness } from './todo-readiness.mjs';
|
|
6
|
+
import { projectTodoStatus, TODO_STATUS_DISPATCH_ONLY } from './todo-status.mjs';
|
|
7
|
+
|
|
8
|
+
const byText = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
|
|
9
|
+
|
|
10
|
+
/** The journal event that put a task or phase in its current state: its latest event. */
|
|
11
|
+
function latestEvent(member, match) {
|
|
12
|
+
const event = member?.journal.events.findLast(match);
|
|
13
|
+
return event === undefined ? null : event;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function triggerOf(member, event, ref) {
|
|
17
|
+
return {
|
|
18
|
+
plan_key: member.plan.plan_key, ...ref, kind: event.kind,
|
|
19
|
+
event_digest: event.event_digest, recorded_at: event.recorded_at, actor: event.actor ?? null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Open notices: ready tasks (`next_ready`, the same rule as `todo status`) that waited on something.
|
|
25
|
+
* `declared(planKey, taskId)` says whether an enforced plan's witness set records the task's row.
|
|
26
|
+
*/
|
|
27
|
+
export function projectTodoNotices(store, { lane = null, declared = () => true } = {}) {
|
|
28
|
+
const readiness = createTodoReadiness(store);
|
|
29
|
+
const members = new Map(store.members.map((member) => [member.plan.plan_key, member]));
|
|
30
|
+
const notices = [];
|
|
31
|
+
for (const ready of projectTodoStatus(store, TODO_STATUS_DISPATCH_ONLY).next_ready) {
|
|
32
|
+
const member = members.get(ready.plan_key);
|
|
33
|
+
const task = member?.plan.tasks.find(({ task_id: id }) => id === ready.task_id);
|
|
34
|
+
if (task === undefined || (lane !== null && task.lane !== lane)) continue;
|
|
35
|
+
const refs = readiness.prerequisiteRefs(readiness.key({ ...member.plan, ...task }));
|
|
36
|
+
const triggers = [];
|
|
37
|
+
for (const ref of refs.tasks) {
|
|
38
|
+
const event = latestEvent(members.get(ref.plan_key), (entry) => entry.task_id === ref.task_id);
|
|
39
|
+
if (event !== null) triggers.push(triggerOf(members.get(ref.plan_key), event, { task_id: ref.task_id }));
|
|
40
|
+
}
|
|
41
|
+
const ownPhase = member.plan.phases?.find(({ phase_id: id }) => id === task.phase_id);
|
|
42
|
+
const phaseRefs = [...refs.phases, ...(ownPhase?.predecessor_phase_ids ?? [])
|
|
43
|
+
.map((phaseId) => ({ plan_key: member.plan.plan_key, phase_id: phaseId }))];
|
|
44
|
+
for (const ref of phaseRefs) {
|
|
45
|
+
const event = latestEvent(members.get(ref.plan_key),
|
|
46
|
+
(entry) => entry.phase_id === ref.phase_id && entry.task_id === undefined);
|
|
47
|
+
if (event !== null) triggers.push(triggerOf(members.get(ref.plan_key), event, { phase_id: ref.phase_id }));
|
|
48
|
+
}
|
|
49
|
+
const own = latestEvent(member, (entry) => entry.task_id === task.task_id);
|
|
50
|
+
if (own?.kind === 'unblock') triggers.push(triggerOf(member, own, { task_id: task.task_id }));
|
|
51
|
+
// A task that waited on nothing was never waited on; next_ready already shows it.
|
|
52
|
+
if (triggers.length === 0) continue;
|
|
53
|
+
const unique = [...new Map(triggers.map((entry) => [entry.event_digest, entry])).values()]
|
|
54
|
+
.sort((left, right) => byText(left.event_digest, right.event_digest));
|
|
55
|
+
const planKey = member.plan.plan_key;
|
|
56
|
+
const mode = member.coordination?.mode ?? null;
|
|
57
|
+
notices.push({
|
|
58
|
+
notice_id: digestTodoArtifact([planKey, member.plan.plan_version, task.task_id,
|
|
59
|
+
unique.map(({ event_digest: digest }) => digest)]),
|
|
60
|
+
plan_key: planKey,
|
|
61
|
+
plan_version: member.plan.plan_version,
|
|
62
|
+
task_id: task.task_id,
|
|
63
|
+
title: task.title,
|
|
64
|
+
lane: task.lane ?? null,
|
|
65
|
+
done_condition: task.done_condition ?? null,
|
|
66
|
+
coordination_mode: mode,
|
|
67
|
+
triggers: unique,
|
|
68
|
+
// Same rule as the enforced done hints (#141): offer what the start path accepts.
|
|
69
|
+
next_action: mode === 'enforced' && !declared(planKey, task.task_id)
|
|
70
|
+
? `lattice todo independence witness declare --plan ${planKey} --task ${task.task_id} --owns <path>[,<path>...]`
|
|
71
|
+
: `lattice todo start --plan ${planKey} --task ${task.task_id}`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return notices.sort((left, right) => byText(`${left.plan_key}\0${left.task_id}`, `${right.plan_key}\0${right.task_id}`));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Notices open after a write and not before it: the `notices` of a mutation result. */
|
|
78
|
+
export function newTodoNotices(before, after) {
|
|
79
|
+
const open = new Set(before.map(({ notice_id: id }) => id));
|
|
80
|
+
return after.filter(({ notice_id: id }) => !open.has(id));
|
|
81
|
+
}
|
package/src/todo-readiness.mjs
CHANGED
|
@@ -126,10 +126,28 @@ export function createTodoReadiness(store) {
|
|
|
126
126
|
}
|
|
127
127
|
const startedSuccessor = (key) => startedSuccessors(key).length > 0;
|
|
128
128
|
|
|
129
|
+
/** notice-impl: what a task waits on — predecessor tasks, phases whose accept it needs, and its own phase. */
|
|
130
|
+
function prerequisiteRefs(key) {
|
|
131
|
+
const node = nodes.get(key);
|
|
132
|
+
const tasks = [...(incoming.get(key) ?? [])].map((source) => nodes.get(source))
|
|
133
|
+
.filter((pred) => pred !== undefined).map(({ plan_key, task_id }) => ({ plan_key, task_id }));
|
|
134
|
+
const phaseRefs = [...(acceptanceIncoming.get(key) ?? [])].map((source) => phases.get(source))
|
|
135
|
+
.filter((phase) => phase !== undefined).map(({ plan_key, phase_id }) => ({ plan_key, phase_id }));
|
|
136
|
+
for (const source of incoming.get(key) ?? []) {
|
|
137
|
+
const pred = nodes.get(source);
|
|
138
|
+
if (pred !== undefined && isPhaseTodoPlanSchema(pred.schema) && !isDecoupledPhaseTodoPlanSchema(pred.schema)
|
|
139
|
+
&& !(pred.plan_key === node?.plan_key && pred.phase_id === node?.phase_id)) {
|
|
140
|
+
phaseRefs.push({ plan_key: pred.plan_key, phase_id: pred.phase_id });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { tasks: uniqueRefs(tasks).sort(byRef), phases: uniqueRefs(phaseRefs).sort(byRef) };
|
|
144
|
+
}
|
|
145
|
+
|
|
129
146
|
return {
|
|
130
147
|
key: taskKey,
|
|
131
148
|
status: (key) => nodes.get(key)?.status,
|
|
132
149
|
prerequisites,
|
|
150
|
+
prerequisiteRefs,
|
|
133
151
|
ownPhaseReady,
|
|
134
152
|
ownPhaseStatus,
|
|
135
153
|
isReady: (key) => nodes.get(key)?.status === 'pending'
|
|
@@ -19,6 +19,7 @@ const STORE_PATHS = [STORE_REF,
|
|
|
19
19
|
':(exclude,glob).lattice/todo/**/.write.lock*',
|
|
20
20
|
':(exclude,glob).lattice/todo/**/.write.lock*/**',
|
|
21
21
|
':(exclude,glob).lattice/todo/.cross-plan-recovery/**',
|
|
22
|
+
':(exclude,glob).lattice/todo/notices/**',
|
|
22
23
|
];
|
|
23
24
|
const LOCK_NAME = 'lattice-todo-store-commit.lock';
|
|
24
25
|
|
package/src/todo-store.mjs
CHANGED
|
@@ -130,7 +130,7 @@ function rejectUnsupportedRevisionSchema(value, { family, supportedSchemas }) {
|
|
|
130
130
|
|
|
131
131
|
// Reader registration (newer-value-says-upgrade): the newest schema of each Store record family this
|
|
132
132
|
// reader knows. Bump it in the same diff that teaches the validator a new version.
|
|
133
|
-
export const NEWEST_KNOWN_TODO_SCHEMA = Object.freeze({ todo_event: 4, todo_plan: 8, todo_manifest: 2 });
|
|
133
|
+
export const NEWEST_KNOWN_TODO_SCHEMA = Object.freeze({ todo_event: 4, todo_plan: 8, todo_manifest: 2, todo_notice_acks: 1 });
|
|
134
134
|
const NEWER_SCHEMA_FAMILY = new Map([[validateTodoPlan, 'todo_plan'], [validateTodoManifest, 'todo_manifest']]);
|
|
135
135
|
const vocabularyWord = (value) => typeof value === 'string' && /^[a-z][a-z0-9_-]{0,63}$/u.test(value);
|
|
136
136
|
|
|
@@ -162,6 +162,12 @@ function failNewer({ pointer, value }, ref) {
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/** Side records outside the lifecycle (the notice ack set) use the same upgrade refusal. */
|
|
166
|
+
export function rejectNewerTodoSchema(value, family, ref) {
|
|
167
|
+
const newer = newerSchema(value, family);
|
|
168
|
+
if (newer !== null) failNewer(newer, ref);
|
|
169
|
+
}
|
|
170
|
+
|
|
165
171
|
function requireWriter(writer, caller) {
|
|
166
172
|
if (!exactRecord(writer, ['schema', 'caller']) || writer.schema !== 'lattice.todo_store_writer.v1'
|
|
167
173
|
|| writer.caller !== caller) throw new TypeError(`writer capability for ${caller} required`);
|
|
@@ -2098,7 +2104,7 @@ export async function readTodoStoreForDisplay({ repoRoot = process.cwd(), now }
|
|
|
2098
2104
|
return { state: 'unavailable', store: null, verified_at: null, source: null, inconsistency, dropped_members: dropped };
|
|
2099
2105
|
}
|
|
2100
2106
|
|
|
2101
|
-
async function atomicWrite(absolute, bytes) {
|
|
2107
|
+
export async function atomicWrite(absolute, bytes) {
|
|
2102
2108
|
await mkdir(path.dirname(absolute), { recursive: true });
|
|
2103
2109
|
const temporary = path.join(path.dirname(absolute), `.${path.basename(absolute)}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`);
|
|
2104
2110
|
let handle;
|
|
@@ -3425,13 +3431,17 @@ export async function initializeTodoStore(options = {}) {
|
|
|
3425
3431
|
const sameDirectoryIdentity = (left, right) => left !== null && right !== null
|
|
3426
3432
|
&& left.dev === right.dev && left.ino === right.ino;
|
|
3427
3433
|
|
|
3428
|
-
|
|
3434
|
+
// Host-local notice ack sets (and their temp files) of a store that is gone; see todo-notice-store.mjs.
|
|
3435
|
+
const NOTICE_ACK_RESIDUE = /^(?:\.gitignore|\.?[0-9a-f]{16}\.json(?:\.\d+\.[0-9a-f]{12}\.tmp)?)$/u;
|
|
3436
|
+
|
|
3437
|
+
async function transientStoreDirectory(root, allowNotes = true, allowAcks = false) {
|
|
3429
3438
|
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
3430
|
-
if (entry.isFile() && (entry.name === '.write.lock' || /^\.write\.lock\..+\.(?:tmp|stale)$/u.test(entry.name)
|
|
3439
|
+
if (entry.isFile() && (entry.name === '.write.lock' || /^\.write\.lock\..+\.(?:tmp|stale)$/u.test(entry.name)
|
|
3440
|
+
|| (allowAcks && NOTICE_ACK_RESIDUE.test(entry.name)))) continue;
|
|
3431
3441
|
if (!entry.isDirectory()) return false;
|
|
3432
3442
|
const child = path.join(root, entry.name);
|
|
3433
|
-
if (allowNotes && entry.name
|
|
3434
|
-
if (!await transientStoreDirectory(child, false)) return false;
|
|
3443
|
+
if (allowNotes && ['notes', 'notices'].includes(entry.name)) {
|
|
3444
|
+
if (!await transientStoreDirectory(child, false, entry.name === 'notices')) return false;
|
|
3435
3445
|
} else if (['.cross-plan-recovery', '.write.lock.recovery'].includes(entry.name)) {
|
|
3436
3446
|
for (const claim of await readdir(child, { withFileTypes: true })) {
|
|
3437
3447
|
if (!claim.isDirectory() || (await readdir(path.join(child, claim.name))).length !== 0) return false;
|
|
@@ -3507,6 +3517,30 @@ async function prepareAuthoredStoreRoot(repoRoot, options) {
|
|
|
3507
3517
|
});
|
|
3508
3518
|
}
|
|
3509
3519
|
}
|
|
3520
|
+
// Acks of the store that is gone name notices that cannot open again; losing them is redelivery at most.
|
|
3521
|
+
const notices = path.join(root, 'notices');
|
|
3522
|
+
const noticesIdentity = await lstat(notices).catch((error) => {
|
|
3523
|
+
if (error?.code !== 'ENOENT') throw error;
|
|
3524
|
+
return null;
|
|
3525
|
+
});
|
|
3526
|
+
if (noticesIdentity !== null) {
|
|
3527
|
+
await withStoreLock({ lockPath: path.join(notices, '.write.lock'), createParent: false }, async () => {
|
|
3528
|
+
if (!sameDirectoryIdentity(noticesIdentity, await lstat(notices))
|
|
3529
|
+
|| !await transientStoreDirectory(notices, false, true)) {
|
|
3530
|
+
fail('STORE_WRITE_CONFLICT', 'authoring_activation_path_changed');
|
|
3531
|
+
}
|
|
3532
|
+
for (const name of await readdir(notices)) {
|
|
3533
|
+
if (NOTICE_ACK_RESIDUE.test(name)) await rm(path.join(notices, name), { force: true });
|
|
3534
|
+
}
|
|
3535
|
+
});
|
|
3536
|
+
try { await rmdir(notices); }
|
|
3537
|
+
catch (error) {
|
|
3538
|
+
if (!['ENOTEMPTY', 'EEXIST'].includes(error?.code)) throw error;
|
|
3539
|
+
throw new StoreLockError('store_locked', path.join(notices, '.write.lock'), {
|
|
3540
|
+
next_action: `Confirm no writer before clearing abandoned host-local notice lock residue in ${notices}`,
|
|
3541
|
+
});
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3510
3544
|
await protocolStage(options, 'authoring_residue_locked');
|
|
3511
3545
|
}); } catch (error) {
|
|
3512
3546
|
const gone = (await uninitializedStoreLayout(repoRoot)).identity === null;
|