@quolu/lattice 0.104.0 → 0.106.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/README.ja.md CHANGED
@@ -323,7 +323,7 @@ required evidenceを束縛した`todo phase accept`で重監査の判断を記
323
323
 
324
324
  **監査の既定は「有り」です。** phaseを持たないplanも終端に重監査が要ります(予約Phase
325
325
  `terminal-audit`を暗黙に1つ持ちます)。全taskがdoneになった状態は「完走」ではなく`gate_ready`=
326
- **監査待ち**であり、工程図のlive scopeはそのplanのToDoを畳みません——完走扱いで図から消えることが
326
+ **監査前**であり、工程図のlive scopeはそのplanのToDoを畳みません——完走扱いで図から消えることが
327
327
  「閉じた」の可視表現なので、監査の記録なしにそこへ行かせません。作成時に拒否はせず、
328
328
  `todo migrate`/`plan create`の結果と最後のdoneのadvisoryで`terminal_audit_required`を通知します。
329
329
  **終端監査はToDoのdispatch可否へ影響しません**(Phaseは重監査の順序だけを制御し、開始順はToDo DAGが決めます)。
@@ -341,14 +341,14 @@ lattice todo phase accept --plan <key> --phase terminal-audit --evidence <監査
341
341
 
342
342
  **過去の工程は監査できません。** 監査対象のコードが既に変化しているためです。そこで
343
343
  「監査なしで閉じた」という状態を別に持ちます——`accepted`(監査を通った)へは絶対に化けず、
344
- 記録は永久に区別できます。工程図では畳まれるので監査待ちの札は外れます。
344
+ 記録は永久に区別できます。工程図では畳まれるので監査前の札は外れます。
345
345
 
346
346
  ```bash
347
347
  lattice todo phase close-unaudited --plan <key> --phase terminal-audit --reason <text>
348
348
  lattice todo phase baseline --reason <text> --except <監査したいplan_key> # 一括
349
349
  ```
350
350
 
351
- 一括の入口は、現在監査待ちで一度も監査に触れていないPhaseだけを対象にします。**自動では
351
+ 一括の入口は、現在監査前で一度も監査に触れていないPhaseだけを対象にします。**自動では
352
352
  実行しません**——どれを監査し、どれを歴史として畳むかは人が決め、Latticeは宣言を受け取って
353
353
  記録するだけです。`--except`は「最近の作業でコードも生きているので本当に監査したい」planを
354
354
  残すための口です。規約は
@@ -376,7 +376,7 @@ dashboardはmanifestのfile identityが変わらない間のstable store readを
376
376
  巨大工程図のrender中にhealth応答が遅れても、生存中dashboardを新daemonで置き換えず
377
377
  `DASHBOARD_DAEMON_UNRESPONSIVE`としてtyped拒否します。
378
378
  最近のsession activityが1週間を過ぎても、Lattice storeの`active_set`が非空なproject、
379
- または監査待ちPhaseがあるprojectは一覧へ残ります。
379
+ または監査前Phaseがあるprojectは一覧へ残ります。
380
380
  長時間の外部処理中にCLI呼出しが途切れても進行中projectを休眠扱いしません。
381
381
  LANや外部reverse proxyから閲覧するoptional bridgeは既定で無効です。明示したIPにだけbindする初回設定、
382
382
  再設定、停止方法は[bridge setup](docs/bridge-setup.md)を参照してください。reverse proxy hostへsshで
@@ -205,8 +205,8 @@ hubへ繋いでいる端末では、`runtime.last_heartbeat`が最後にhubへ
205
205
  | `null` | hub未設定、またはまだ1回も送っていない | — |
206
206
 
207
207
  名乗る集合はdaemonが実際に配信している集合そのもの(ADR 0165)。配信集合は
208
- `last_seen_at`が1週間以内、またはactive run、または監査待ちPhaseがあるprojectである。
209
- 人がCLIを叩かなくても、その条件を満たす限り公開面に残る。1週間を超え、runも監査待ちも
208
+ `last_seen_at`が1週間以内、またはactive run、または監査前Phaseがあるprojectである。
209
+ 人がCLIを叩かなくても、その条件を満たす限り公開面に残る。1週間を超え、runも監査前も
210
210
  無いprojectは配信から外れる。heartbeatの90秒TTLは、配信そのものが止まった時
211
211
  (daemon停止)にofflineへ落とすためのもので、鮮度窓ではない。
212
212
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.104.0",
3
+ "version": "0.106.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
@@ -110,6 +110,7 @@ Read commands:
110
110
 
111
111
  Write commands:
112
112
  notice ack --lane <lane> --notice <id>[,<id>...] [--json] # 届けた知らせに印を付ける(閉じた知らせはclosedで返す)
113
+ compact [--plan <key>] [--limit <n>] [--json] # 退避済みの版のplan.json・revision.json・snapshot.jsonを、後継との差分(compact.json)だけに置き換える(既定40版まで。続きは再実行)
113
114
  repair-eol --json # Git checkoutでCRLF化された既存storeをcanonical LFへ戻し、EOL保護を追加する
114
115
  dashboard adopt --json # 衝突したproject_idの配信元rootを現在repoへ明示的に移す
115
116
  dashboard ensure --json # daemon生存保証の冪等入口(launchd等の周期実行向け)
@@ -331,6 +332,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
331
332
  'todo notice': 'todo notice list [--lane <lane>] [--include-acked] [--json] | ack --lane <lane> --notice <id>[,<id>...] [--json]',
332
333
  'todo notice list': 'todo notice list [--lane <lane>] [--include-acked] [--json] # lattice.todo_notice_list_result.v1',
333
334
  'todo notice ack': 'todo notice ack --lane <lane> --notice <id>[,<id>...] [--json] # lattice.todo_notice_ack_result.v1 {acked, already, closed}',
335
+ 'todo compact': 'todo compact [--plan <key>] [--limit <n>] [--json] # lattice.todo_compact_result.v1 {plans: [{plan_key, compacted, stopped, next_version}]}',
334
336
  'todo blockers': 'todo blockers [--json] # lattice.todo_blockers_result.v1 {blockers: [{plan_key, task_id, title, lane, reason, blocked_at, blocked_by, unblock_action}]}',
335
337
  'todo wait': 'todo wait --plan <key> --task <id> [--reason <text>] | --cancel [--json] # 廃止予定の別名: todo connect priority',
336
338
  'todo bindings': 'todo bindings [--plan <key>] [--json]',
@@ -319,7 +319,7 @@ async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts
319
319
  // 監査/構造finalization待ちが在る限り「残作業なし」と答えない。優先順位は
320
320
  // active_run > next_ready > structure finalization > audit_pending > なし。
321
321
  // ready frontierが在る間はADR 0063の並列開始コマンドが勝つ
322
- // ——ここを監査で上書きするとdispatchが再直列化する。監査待ちはtodo statusの
322
+ // ——ここを監査で上書きするとdispatchが再直列化する。監査前はtodo statusの
323
323
  // audit_pending欄に常在するので、順位を下げても消えない。
324
324
  // gate_ready(全taskが終わり監査も未着手)は軽い出口close-unauditedを1行で示す(a22)。
325
325
  // 監査を始めた後(reviewing/rejected)は読み取り専用の`todo phase status`が両分岐を示す。
@@ -1,19 +1,19 @@
1
1
  /**
2
- * 監査待ちPhaseの定義(ADR 0147/0148)。
2
+ * 監査前Phaseの定義(ADR 0147/0148)。
3
3
  *
4
- * 「監査待ち」は同じ3状態の集合として、gantt scopeのfold判定・dashboardの表示判定へ
4
+ * 「監査前」は同じ3状態の集合として、gantt scopeのfold判定・dashboardの表示判定へ
5
5
  * 別々に書かれていた。status面にも同じ判定が要るので、定義をここへ一本化する——
6
6
  * 集合が三重になれば、片方だけ更新された時に「図には出るがstatusには出ない」形の
7
7
  * ずれが生まれる。ADR 0147が塞ごうとした事故と外形が同じになる。
8
8
  *
9
- * このmoduleが持つのは監査待ちの**定義**だけである。各消費者の方針
9
+ * このmoduleが持つのは監査前の**定義**だけである。各消費者の方針
10
10
  * (ganttのfold対象をどのplan世代へ限るか等)はここへ持ち込まない。
11
11
  */
12
12
 
13
13
  /**
14
14
  * 監査の判断がまだ着いていないPhase状態。
15
15
  *
16
- * - `gate_ready`: 所属ToDoが全てdoneで、監査待ち。
16
+ * - `gate_ready`: 所属ToDoが全てdoneで、監査前。
17
17
  * - `reviewing`: 監査中(reviewは出たが、acceptもrejectも出ていない)。
18
18
  * - `rejected`: 監査が通らず、要フォロー。
19
19
  *
@@ -23,19 +23,19 @@
23
23
  */
24
24
  export const AUDIT_PENDING_PHASE_STATUSES = new Set(['gate_ready', 'reviewing', 'rejected']);
25
25
 
26
- /** そのPhase状態が監査待ちか。null/undefined/未知の値はfalse。 */
26
+ /** そのPhase状態が監査前か。null/undefined/未知の値はfalse。 */
27
27
  export function isAuditPendingPhaseStatus(status) {
28
28
  return AUDIT_PENDING_PHASE_STATUSES.has(status ?? null);
29
29
  }
30
30
 
31
31
  /**
32
- * その監査待ち状態から実際に打てるコマンド。
32
+ * その監査前状態から実際に打てるコマンド。
33
33
  *
34
34
  * `src/todo-store.mjs`の遷移guardと一致させる——gate_readyからいきなりacceptはできず
35
35
  * (`phase_gate_not_ready`)、reviewing以外からのrejectもできない(`phase_reject_binding_invalid`)。
36
36
  * 実行すれば必ず弾かれる遷移を「次の一歩」として案内しない。
37
37
  *
38
- * 監査待ちでない状態を渡すのは呼び出し側の誤りなので、空配列へ丸めずに投げる。
38
+ * 監査前でない状態を渡すのは呼び出し側の誤りなので、空配列へ丸めずに投げる。
39
39
  * 呼ぶ前に`isAuditPendingPhaseStatus`で絞ること。
40
40
  *
41
41
  * `slotCount`は必須evidence slotの数。1つなら`--evidence`で足り、複数なら`--input`が要る。
@@ -73,7 +73,7 @@ export function phaseAuditRequired(member, gatePolicy) {
73
73
  }
74
74
 
75
75
  /**
76
- * store read model(`lattice.todo_store_read.v1`)の中の監査待ちPhaseを列挙する。
76
+ * store read model(`lattice.todo_store_read.v1`)の中の監査前Phaseを列挙する。
77
77
  *
78
78
  * `member.phases`はstoreが常に埋める導出ビューで、phase無しplanの暗黙terminal-audit Phaseも
79
79
  * 同じ形で入っている(ADR 0147)。planの世代で分岐しないのはそのためである。
package/src/todo-cli.mjs CHANGED
@@ -65,11 +65,13 @@ import {
65
65
  appendTodoStructureRealization,
66
66
  applyPhaseTodoRevision,
67
67
  applyTodoRevision,
68
+ compactTodoVersions,
68
69
  applyTodoRevisionSet,
69
70
  buildTodoPlan,
70
71
  createTodoStoreWriter,
71
72
  TodoStoreError,
72
73
  isPhaselessTodoPlanSchema,
74
+ findUnverifiedTodoEvidence,
73
75
  isTodoEvidenceUncommitted,
74
76
  isUninitializedTodoStore,
75
77
  projectTodoCrossPlanDependencies,
@@ -314,7 +316,7 @@ const TODO_COMMAND_NAMES = Object.freeze([
314
316
  'status', 'show', 'note', 'bindings', 'display', 'independence', 'structure', 'seam-profile', 'seam-proposal',
315
317
  'verify', 'repair-eol', 'snapshot', 'gantt', 'dashboard', 'phase', 'migrate', 'start', 'block',
316
318
  'unblock', 'retire', 'done', 'reopen', 'evidence', 'split', 'revise', 'revise-phase', 'revise-set',
317
- 'retract', 'dependency', 'predecessor', 'connect', 'add', 'notice', 'wait', 'blockers',
319
+ 'retract', 'dependency', 'predecessor', 'connect', 'add', 'notice', 'wait', 'blockers', 'compact',
318
320
  ]);
319
321
 
320
322
  function typedArgumentFailure(stderr, code, message, detail, context = {}) {
@@ -384,6 +386,7 @@ const TODO_FLAG_SPECS = Object.freeze({
384
386
  'notice list': Object.freeze({ known: ['lane', 'include-acked', 'json'], required: [], booleans: ['include-acked', 'json'] }),
385
387
  'notice ack': Object.freeze({ known: ['lane', 'notice', 'json'], required: ['lane', 'notice'], booleans: ['json'] }),
386
388
  blockers: Object.freeze({ known: ['json'], required: [], booleans: ['json'] }),
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'] }),
389
392
  'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
@@ -2340,7 +2343,7 @@ async function phaseStatus({ repoRoot, planKey }) {
2340
2343
  // 無いのでsnapshot.phasesは直接読まない)。ここでPHASE_UNAVAILABLEへ拒否せず、その暗黙Phase
2341
2344
  // をそのまま返す——`implicit`で機械可読に「宣言されたPhaseではない」ことを示す。
2342
2345
  const implicit = isPhaselessTodoPlanSchema(member.plan.schema);
2343
- // ADR 0148裁定8: gate_readyのPhaseには、なぜ監査待ちになったかと次の一歩をここでも言う
2346
+ // ADR 0148裁定8: gate_readyのPhaseには、なぜ監査前になったかと次の一歩をここでも言う
2344
2347
  // (todo doneのadvisoryと同じ文言)。implicit(暗黙のterminal-audit Phase)に限らず、
2345
2348
  // v4/v5の実Phaseがgate_readyになった場合も同じ理由で同じ案内が要る。
2346
2349
  const phases = member.phases.map((phase) => ({
@@ -2537,7 +2540,7 @@ async function migrate({ repoRoot, inputRef }) {
2537
2540
  next_action: `lattice todo revise-phase --plan ${imported.plan.plan_key} --input <phase-revision.json>`,
2538
2541
  } : null,
2539
2542
  // ob03: 起票直後のplanは必ず調整方式が未宣言である。ここで案内しないと、選ぶ機会が
2540
- // 「誰も呼ぶ動機の無いdrilldown」にしか無くなる——前campaignの監査待ちと同じ形になる。
2543
+ // 「誰も呼ぶ動機の無いdrilldown」にしか無くなる——前campaignの監査前と同じ形になる。
2541
2544
  coordination_guidance: imported.connectionOnly === true ? null : {
2542
2545
  mode: null,
2543
2546
  modes: [...TODO_COORDINATION_MODES],
@@ -5282,7 +5285,8 @@ async function evidenceAnchor({ repoRoot }) {
5282
5285
  }
5283
5286
 
5284
5287
  async function verify({ repoRoot, requestedPlanKey }) {
5285
- const store = await readTodoStore({ repoRoot });
5288
+ // k4: the full history checks (hash chain, canonical bytes, whole-snapshot comparison) run only here, on request.
5289
+ const store = await readTodoStore({ repoRoot, verifyHistory: true });
5286
5290
  const members = selectMembers(store, requestedPlanKey);
5287
5291
  // note chainはlifecycle storeと独立だが、verifyは両方を検査する。破損を空扱いしない。
5288
5292
  for (const member of members) {
@@ -5293,8 +5297,8 @@ async function verify({ repoRoot, requestedPlanKey }) {
5293
5297
  for (const member of members) {
5294
5298
  const planKey = member.descriptor.plan_key;
5295
5299
  // a12: evidence waiting for a commit is an item; missing or changed evidence still refuses.
5296
- const pending = member.tasks.filter((task) => task.evidence_unverified
5297
- && isTodoEvidenceUncommitted({ repoRoot, store, evidence: task.evidence }));
5300
+ const unverifiedTasks = findUnverifiedTodoEvidence({ repoRoot, store, member });
5301
+ const pending = unverifiedTasks.filter((task) => isTodoEvidenceUncommitted({ repoRoot, store, evidence: task.evidence }));
5298
5302
  for (const { task_id: taskId, evidence } of pending) {
5299
5303
  uncommittedEvidence.push({ plan_key: planKey, task_id: taskId, ...uncommittedEvidenceItem(repoRoot, store, evidence) });
5300
5304
  }
@@ -5302,7 +5306,7 @@ async function verify({ repoRoot, requestedPlanKey }) {
5302
5306
  if (decisionEvidenceState(repoRoot, store, evidence) !== 'uncommitted') continue;
5303
5307
  uncommittedEvidence.push({ plan_key: planKey, phase_id: phaseId, ...uncommittedEvidenceItem(repoRoot, store, evidence) });
5304
5308
  }
5305
- const unverified = member.tasks.find((task) => task.evidence_unverified && !pending.includes(task));
5309
+ const unverified = unverifiedTasks.find((task) => !pending.includes(task));
5306
5310
  if (unverified !== undefined) {
5307
5311
  throw new TodoStoreError('STORE_INCONSISTENT', 'evidence_unverified', 'evidence_unverified', {
5308
5312
  plan_key: member.descriptor.plan_key,
@@ -5572,6 +5576,13 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
5572
5576
  if (isNoticeLane(flags.lane) && ids.length > 0 && ids.every((id) => /^[0-9a-f]{64}$/u.test(id))) {
5573
5577
  action = (repoRoot) => noticeAck({ repoRoot, env, lane: flags.lane, ids });
5574
5578
  }
5579
+ } else if (argv[0] === 'compact' && matchFlagCommand(argv, ['compact'], TODO_FLAG_SPECS.compact) !== null) {
5580
+ // b10: retained versions keep only their difference from the successor; this finishes the ones written before.
5581
+ const flags = matchFlagCommand(argv, ['compact'], TODO_FLAG_SPECS.compact);
5582
+ if ((flags.plan === undefined || isTodoIdentifier(flags.plan)) && (flags.limit === undefined || /^[1-9]\d{0,5}$/u.test(flags.limit))) {
5583
+ action = (repoRoot) => compactTodoVersions({ repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }),
5584
+ planKey: flags.plan, limit: flags.limit === undefined ? 40 : Number(flags.limit) });
5585
+ }
5575
5586
  } else if (argv[0] === 'blockers' && matchFlagCommand(argv, ['blockers'], TODO_FLAG_SPECS.blockers) !== null) {
5576
5587
  action = (repoRoot) => blockerList({ repoRoot });
5577
5588
  } else if ((argv[0] === 'connect' && argv[1] === 'priority' || argv[0] === 'wait')
@@ -246,6 +246,9 @@ export function validateTodoNoteContext(value) {
246
246
  }
247
247
 
248
248
  const nullableDigest = (value) => value === null || isTodoDigest(value);
249
+ /** k4: a done recorded as plain text. The task's `evidence` is `{message}` (carried across revisions like any evidence). */
250
+ export const isTodoDoneMessage = (value) => exactRecord(value, ['message']) && typeof value.message === 'string'
251
+ && value.message.trim().length > 0 && Buffer.byteLength(value.message) <= TODO_LIMITS.noteBodyBytes;
249
252
  const nullableText = (value) => value === null || (typeof value === 'string' && value.length > 0 && Buffer.byteLength(value) <= 16_384);
250
253
  /** 設計メモの拒否理由を、本文をerrorへ複製せずAIが訂正できる形で返す。 */
251
254
  export function explainTodoDesignMemo(value) {
@@ -632,6 +635,14 @@ function validPayload(event) {
632
635
  && ['pending', 'blocked', 'in-progress', 'done'].includes(payload.prior_status)))
633
636
  && nullableText(payload.reason) && payload.reason !== null;
634
637
  }
638
+ if (event.kind === 'done' && payload?.done_mode === 'authored' && typeof payload.message === 'string') {
639
+ // k4: a new done record is plain text in the event (no blob, descriptor or digest). Legacy `evidence` records stay valid below.
640
+ return (exactRecord(payload, ['done_mode', 'imported', 'message'])
641
+ || exactRecord(payload, ['done_mode', 'imported', 'message', 'test_result']))
642
+ && payload.imported === false && payload.message.trim().length > 0
643
+ && Buffer.byteLength(payload.message) <= TODO_LIMITS.noteBodyBytes
644
+ && (payload.test_result === undefined || isTodoTestResult(payload.test_result));
645
+ }
635
646
  if (event.kind === 'done' && payload?.done_mode === 'authored') {
636
647
  return (exactRecord(payload, ['done_mode', 'imported', 'evidence'])
637
648
  || exactRecord(payload, ['done_mode', 'imported', 'evidence', 'test_result']))
@@ -656,6 +667,18 @@ function validPayload(event) {
656
667
  && nullableText(payload.override_reason);
657
668
  if (event.kind === 'phase_review') return exactRecord(payload, ['reason'])
658
669
  && nullableText(payload.reason) && payload.reason !== null;
670
+ // k4: a new accept/reject carries no evidence descriptor or slots; an optional plain-text `message` (same limits as done's).
671
+ const planMessage = (value) => typeof value === 'string' && value.trim().length > 0
672
+ && Buffer.byteLength(value) <= TODO_LIMITS.noteBodyBytes;
673
+ if (event.kind === 'phase_accept' && (exactRecord(payload, ['review_event_digest'])
674
+ || exactRecord(payload, ['review_event_digest', 'message']))) {
675
+ return isTodoDigest(payload.review_event_digest) && (payload.message === undefined || planMessage(payload.message));
676
+ }
677
+ if (event.kind === 'phase_reject' && (exactRecord(payload, ['review_event_digest', 'reason'])
678
+ || exactRecord(payload, ['review_event_digest', 'reason', 'message']))) {
679
+ return isTodoDigest(payload.review_event_digest) && nullableText(payload.reason) && payload.reason !== null
680
+ && (payload.message === undefined || planMessage(payload.message));
681
+ }
659
682
  if (event.kind === 'phase_accept') return exactRecord(payload, [
660
683
  'review_event_digest', 'decision_evidence', 'evidence_slots',
661
684
  ]) && isTodoDigest(payload.review_event_digest) && evidence(payload.decision_evidence)
@@ -712,7 +735,7 @@ function validCarriedState(value) {
712
735
  // imported doneの現在証拠はimport sourceまたは通常evidence descriptorのどちらも有効。
713
736
  && (value.imported
714
737
  ? validateTodoImportSource(value.evidence) || evidence(value.evidence)
715
- : evidence(value.evidence));
738
+ : evidence(value.evidence) || isTodoDoneMessage(value.evidence));
716
739
  }
717
740
 
718
741
  function validStateMigration(value) {
@@ -848,7 +871,8 @@ export function validateTodoSnapshot(value) {
848
871
  ]) && isTodoIdentifier(entry.task_id) && ['pending', 'in-progress', 'blocked', 'retired', 'done'].includes(entry.status)
849
872
  && (entry.started_at === null || isStrictTodoTimestamp(entry.started_at))
850
873
  && (entry.done_at === null || isStrictTodoTimestamp(entry.done_at)) && nullableText(entry.blocked_reason)
851
- && (entry.evidence === null || evidence(entry.evidence) || validateTodoImportSource(entry.evidence))
874
+ && (entry.evidence === null || evidence(entry.evidence) || validateTodoImportSource(entry.evidence)
875
+ || isTodoDoneMessage(entry.evidence))
852
876
  && typeof entry.evidence_unverified === 'boolean' && typeof entry.imported === 'boolean'
853
877
  && (!resultAware || (entry.status === 'done'
854
878
  ? entry.test_result === null || isTodoTestResult(entry.test_result)
@@ -20,7 +20,7 @@ body{display:grid;grid-template-rows:minmax(0,1fr);height:100vh;margin:0;backgro
20
20
  .gantt-pane{display:grid;grid-template-rows:auto auto minmax(0,1fr);min-width:0;min-height:0;overflow:hidden;background:var(--surface-1)}
21
21
  .pane-divider{width:8px;cursor:col-resize;background:rgba(217,216,212,.5);touch-action:none}
22
22
  .diagram-toolbar{z-index:3;display:flex;align-items:center;gap:8px;padding:8px 16px;border-bottom:1px solid var(--border);background:var(--surface-2);color:var(--text-secondary)}
23
- /* 監査待ちの札が入って以降、ツールバーは幅の奪い合いになる。操作系は縮ませない——
23
+ /* 監査前の札が入って以降、ツールバーは幅の奪い合いになる。操作系は縮ませない——
24
24
  縮むと「等倍」「全体表示」が2行に折れて、押せるが読みにくい形になる。削るのは札の側で、
25
25
  そちらはellipsisと件数の下限を持っている。 */
26
26
  .diagram-toolbar button{flex:0 0 auto;white-space:nowrap;min-height:32px;padding:0 8px;border:1px solid var(--border);border-radius:4px;background:var(--surface-2);color:var(--text-primary);font:500 12px/1.6 system-ui,-apple-system,"Hiragino Sans","Yu Gothic UI",sans-serif}
@@ -21,10 +21,10 @@ function projectDisplayName(readModel, metadata) {
21
21
  }
22
22
 
23
23
  /**
24
- * 監査待ちPhaseをヘッダへ出す(ADR 0147/0148)。
24
+ * 監査前Phaseをヘッダへ出す(ADR 0147/0148)。
25
25
  *
26
26
  * CLIのstdoutは1行のversioned JSONというADR 0049の公理があり、人が読むテキスト面が無い。
27
- * 人が実際に見るのはこの図とdashboard(同じHTMLを配信する)なので、監査待ちはここへ出す。
27
+ * 人が実際に見るのはこの図とdashboard(同じHTMLを配信する)なので、監査前はここへ出す。
28
28
  * 全taskがdoneでも監査が済んでいなければ工程は閉じていない——図が「全部緑」に見えるのに
29
29
  * ヘッダが無言なら、読み手は完了したと読む。
30
30
  *
@@ -33,8 +33,8 @@ function projectDisplayName(readModel, metadata) {
33
33
  * **出す文字列を有界にする。** ツールバーはpane幅で制約されていないので、長い札は縮まずに
34
34
  * 行を押し広げ、ズーム操作を画面外へ追い出す(2026-08-08に実測)。CSSの`text-overflow`は
35
35
  * ここでは発動しないため、頼れない。全plan名を並べる代わりに先頭1件+残件数だけを出し、
36
- * 全文は`title`に残す。件数(`監査待ち N件`)は常に見える——省略するのは内訳であって、
37
- * 監査待ちの存在そのものではない。
36
+ * 全文は`title`に残す。件数(`監査前 N件`)は常に見える——省略するのは内訳であって、
37
+ * 監査前の存在そのものではない。
38
38
  */
39
39
  function renderAuditPendingChip(readModel) {
40
40
  const pending = auditPendingPhasesOf(readModel);
@@ -42,8 +42,8 @@ function renderAuditPendingChip(readModel) {
42
42
  const label = ({ plan_key: planKey, phase_id: phaseId, status }) => `${planKey}/${phaseId} (${status})`;
43
43
  // 残件数は書かない——先頭の`N件`が既に全体を数えており、「ほかM件」はその引き算でしかない。
44
44
  // 幅は有限なので、同じことを二度言う分だけplan名が削れる。
45
- const text = `監査待ち ${pending.length}件: ${label(pending[0])}`;
46
- const full = `監査待ち ${pending.length}件: ${pending.map(label).join(' · ')}`;
45
+ const text = `監査前 ${pending.length}件: ${label(pending[0])}`;
46
+ const full = `監査前 ${pending.length}件: ${pending.map(label).join(' · ')}`;
47
47
  return `<span class="audit-pending-chip" title="${escapeHtmlAttribute(full)}">${escapeHtmlText(text)}</span>`;
48
48
  }
49
49
 
@@ -43,7 +43,7 @@ function compareText(left, right) {
43
43
  /**
44
44
  * ADR 0147: phase無しplan(v1/v2/v3)は終端の暗黙Phase(terminal-audit)がacceptedになるまで
45
45
  * 「閉じた」ことにならない。全taskがdoneでも監査未了なら、そのplanのToDoは生きた作業と同じ
46
- * 扱い(distance 0)にして畳ませない——畳んでしまうと監査待ちであることが図から消え、
46
+ * 扱い(distance 0)にして畳ませない——畳んでしまうと監査前であることが図から消え、
47
47
  * ADR 0147が塞ごうとした「一度も重監査を通らず完走した」事故と外形が同じになる。
48
48
  *
49
49
  * v4/v5(phaseを宣言したplan)はこの判定の対象外にする——既存のPhase gateが重監査を担って
@@ -52,11 +52,11 @@ function compareText(left, right) {
52
52
  * phase無しplanのtaskにはphase_idフィールド自体が無いため、そこでは暗黙Phaseの状態を
53
53
  * 埋める。フィールドが無い/nullの入力(既存test・素のnode)は従来どおり対象外(false)になる。
54
54
  *
55
- * 監査待ちの状態集合そのものは`todo-audit-pending.mjs`が持つ(gate_ready・reviewing・rejected)。
55
+ * 監査前の状態集合そのものは`todo-audit-pending.mjs`が持つ(gate_ready・reviewing・rejected)。
56
56
  * `active`(一部taskがまだpending)が入っていないことにここも依存している——ここまで
57
57
  * 広げると、完走していない枝の通常foldまで止めてしまい既存挙動を変える。
58
58
  *
59
- * 下のv4/v5除外は共有moduleへ移さない。あれは「監査待ちとは何か」の定義ではなく、
59
+ * 下のv4/v5除外は共有moduleへ移さない。あれは「監査前とは何か」の定義ではなく、
60
60
  * ganttがどこまでfoldを止めるかという本moduleの方針である。移すと、宣言Phase planの
61
61
  * fold挙動を他の消費者の都合で変えてしまう。
62
62
  */
@@ -8,6 +8,7 @@ import { LOCK_WAIT_MS, StoreLockError, withStoreLock } from './store-lock.mjs';
8
8
  import { syncPublishedFile } from './fs-publish.mjs';
9
9
  import { normalizeCheckoutEol } from './todo-store-view.mjs';
10
10
  import { memoByFileIdentity } from './todo-version-memo.mjs';
11
+ import { TODO_VERSION_COMPACT_FILE, readVersionCompact } from './todo-version-compact.mjs';
11
12
 
12
13
  import {
13
14
  TODO_LIMITS,
@@ -514,8 +515,25 @@ async function readNoteMigrations(repoRoot, planKey, eventVersions) {
514
515
  const versionRoot = path.join(base, entry.name);
515
516
  const planPath = path.join(versionRoot, 'plan.json');
516
517
  const revisionPath = path.join(versionRoot, 'revision.json');
517
- // perf-store: validated once per process while both files are unchanged (todo-version-memo).
518
- const version = await memoByFileIdentity([planPath, revisionPath], async () => {
518
+ const compactPath = path.join(versionRoot, TODO_VERSION_COMPACT_FILE);
519
+ // perf-store: validated once per process while the files are unchanged (todo-version-memo).
520
+ const version = await memoByFileIdentity([planPath, revisionPath, compactPath], async () => {
521
+ // b10: a superseded version keeps compact.json.gz (its revision, minus the plan it repeats) instead of plan.json/revision.json.
522
+ const compact = await readVersionCompact(versionRoot).catch(() => fail('NOTE_PROJECTION_INVALID',
523
+ 'note_historical_plan_invalid', { plan_version: entry.name }));
524
+ if (compact !== null) {
525
+ if (compact.plan_key !== planKey || compact.plan_version !== entry.name) {
526
+ fail('NOTE_PROJECTION_INVALID', 'note_historical_plan_invalid', { plan_version: entry.name });
527
+ }
528
+ const migration = compact.revision?.task_migration;
529
+ if (compact.revision === null) return { migration: null };
530
+ if (compact.predecessor_plan_version === null || !Array.isArray(migration)) {
531
+ fail('NOTE_PROJECTION_INVALID', 'note_historical_revision_invalid', { plan_version: entry.name });
532
+ }
533
+ return { migration: { from_plan_version: compact.predecessor_plan_version, to_plan_version: entry.name,
534
+ task_migration: migration.map(({ from_task_id: fromTaskId, to_task_id: toTaskId }) => ({
535
+ from_task_id: fromTaskId, to_task_id: toTaskId })) } };
536
+ }
519
537
  // A revision directory is published before manifest activation. A crash during
520
538
  // that window can leave an unreferenced directory containing only a journal
521
539
  // stub. It is not a historical plan until its canonical plan artifact exists.
@@ -165,11 +165,11 @@ function blockedEntry(value) {
165
165
  }
166
166
 
167
167
  /**
168
- * 監査待ちPhase 1件。
168
+ * 監査前Phase 1件。
169
169
  *
170
170
  * task entryと紛れないよう`status`ではなく`phase_status`にする。状態集合は
171
171
  * `todo-audit-pending.mjs`の定義をそのまま使う(ここで書き直さない)。
172
- * `next_commands`を非空必須にしたのは、監査待ちなのに次の一手が空なら次アクション面として
172
+ * `next_commands`を非空必須にしたのは、監査前なのに次の一手が空なら次アクション面として
173
173
  * 無意味だからである(状態集合が閉じている以上、空になる枝は無い)。
174
174
  */
175
175
  function auditPendingEntry(value) {
@@ -401,9 +401,9 @@ export function validateTodoStatusResult(value) {
401
401
  }
402
402
 
403
403
  /**
404
- * memberの監査待ちPhaseを`audit_pending` entryへ起こす。
404
+ * memberの監査前Phaseを`audit_pending` entryへ起こす。
405
405
  *
406
- * 「監査待ちか」の判定は`todo-audit-pending.mjs`、Phase定義(slots)は`todo-store.mjs`の
406
+ * 「監査前か」の判定は`todo-audit-pending.mjs`、Phase定義(slots)は`todo-store.mjs`の
407
407
  * `todoPhaseDefinitions`が正本である。`plan.phases`を直接読むとphase無しplan(v1/v2/v3)と
408
408
  * synthetic read modelで落ちるので読まない。
409
409
  *
@@ -717,7 +717,7 @@ export function projectTodoStatus(readModel, options = undefined) {
717
717
  dispatch_frontier: dispatchFrontier(readModel.project_id, lists.next_ready),
718
718
  blocked: lists.blocked,
719
719
  connection_pending: lists.connection_pending,
720
- // 監査待ちは`member.phases`だけから作った別の列で、dispatch(next_ready/dispatch_frontier)へは
720
+ // 監査前は`member.phases`だけから作った別の列で、dispatch(next_ready/dispatch_frontier)へは
721
721
  // 影響しない。監査が進んでもfrontier_digestは動かない。
722
722
  audit_pending: lists.audit_pending,
723
723
  // 全task done後、構造finalizationが無い/古いplanだけを別列へ出す。監査状態と