@quolu/lattice 0.105.0 → 0.107.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.
@@ -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)
@@ -872,8 +896,12 @@ export function validateTodoChartMeta(value) {
872
896
  const text = (field) => field === null || (typeof field === 'string' && field.length > 0 && field.length <= 1024);
873
897
  const word = (field) => typeof field === 'string' && field.length > 0 && field.length <= 1024;
874
898
  const { repo } = value ?? {};
875
- return exactRecord(value, ['schema', 'name', 'created_by', 'created_at', 'repo'])
876
- && value.schema === TODO_CHART_META_SCHEMA && text(value.name) && text(value.created_by)
899
+ // no_code_lanes is optional: a file without it stays valid, and an empty list is never written (old readers keep working).
900
+ const lanes = value?.no_code_lanes;
901
+ const lanesOk = lanes === undefined || (Array.isArray(lanes) && lanes.every((lane, index) => isTodoIdentifier(lane)
902
+ && (index === 0 || lanes[index - 1] < lane)));
903
+ return exactRecord(value, ['schema', 'name', 'created_by', 'created_at', 'repo', ...(lanes === undefined ? [] : ['no_code_lanes'])])
904
+ && lanesOk && value.schema === TODO_CHART_META_SCHEMA && text(value.name) && text(value.created_by)
877
905
  && (value.created_at === null || isStrictTodoTimestamp(value.created_at))
878
906
  && (repo === null || (exactRecord(repo, ['url', 'branch', 'accepted_tip'])
879
907
  && word(repo.url) && word(repo.branch) && text(repo.accepted_tip)));
@@ -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
  */
@@ -1,11 +1,11 @@
1
1
  import { createHash, randomBytes } from 'node:crypto';
2
2
  import { fsyncDirectory } from './fs-dir-sync.mjs';
3
3
  import {
4
- lstat, mkdir, open, readFile, readdir, rename, rm, stat,
4
+ lstat, mkdir, open, readFile, readdir, rm, stat,
5
5
  } from 'node:fs/promises';
6
6
  import path from 'node:path';
7
7
  import { LOCK_WAIT_MS, StoreLockError, withStoreLock } from './store-lock.mjs';
8
- import { syncPublishedFile } from './fs-publish.mjs';
8
+ import { renamePublishedFile, syncPublishedFile } from './fs-publish.mjs';
9
9
  import { normalizeCheckoutEol } from './todo-store-view.mjs';
10
10
  import { memoByFileIdentity } from './todo-version-memo.mjs';
11
11
  import { TODO_VERSION_COMPACT_FILE, readVersionCompact } from './todo-version-compact.mjs';
@@ -201,7 +201,7 @@ async function atomicWrite(ref, bytes) {
201
201
  await syncPublishedFile(handle, ref);
202
202
  await handle.close();
203
203
  handle = null;
204
- await rename(temporary, ref);
204
+ await renamePublishedFile(temporary, ref);
205
205
  await fsyncDirectory(path.dirname(ref));
206
206
  } finally {
207
207
  if (handle) await handle.close();
@@ -282,7 +282,6 @@ export function validateProspectiveEvent({ store, member, event }) {
282
282
  const definition = todoPhaseDefinitions(member.plan).find(({ phase_id: id }) => id === event.phase_id);
283
283
  return refused('phase_gate_not_ready', 'phase_state', {
284
284
  plan_key: member.plan.plan_key, phase_id: event.phase_id, phase_status: phase.status,
285
- required_evidence_slots: [...(definition?.required_evidence_slots ?? [])],
286
285
  });
287
286
  }
288
287
  }
@@ -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
  *
@@ -436,7 +436,6 @@ function collectAuditPending(member, sink) {
436
436
  implicit,
437
437
  required_evidence_slots: [...definition.required_evidence_slots],
438
438
  next_commands: auditPendingNextCommands(member.plan.plan_key, phase.phase_id, phase.status,
439
- definition.required_evidence_slots.length,
440
439
  { auditRequired: phaseAuditRequired(member, definition.gate_policy) }),
441
440
  });
442
441
  }
@@ -717,7 +716,7 @@ export function projectTodoStatus(readModel, options = undefined) {
717
716
  dispatch_frontier: dispatchFrontier(readModel.project_id, lists.next_ready),
718
717
  blocked: lists.blocked,
719
718
  connection_pending: lists.connection_pending,
720
- // 監査待ちは`member.phases`だけから作った別の列で、dispatch(next_ready/dispatch_frontier)へは
719
+ // 監査前は`member.phases`だけから作った別の列で、dispatch(next_ready/dispatch_frontier)へは
721
720
  // 影響しない。監査が進んでもfrontier_digestは動かない。
722
721
  audit_pending: lists.audit_pending,
723
722
  // 全task done後、構造finalizationが無い/古いplanだけを別列へ出す。監査状態と