@quolu/lattice 0.108.0 → 0.110.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.
Files changed (47) hide show
  1. package/bin/lattice.mjs +2 -2
  2. package/docs/schemas/lattice.plan_create_input.v6.schema.json +384 -0
  3. package/docs/schemas/lattice.plan_revise_input.v1.schema.json +3 -0
  4. package/docs/schemas/lattice.todo_witness_draft.v2.schema.json +14 -2
  5. package/docs/schemas/lattice.todo_witness_set.v6.schema.json +482 -0
  6. package/package.json +3 -1
  7. package/sensor/dist/bin/lattice-sensor.js +76 -0
  8. package/sensor/dist/graph/anchor-resolve.d.ts +90 -0
  9. package/sensor/dist/graph/anchor-resolve.d.ts.map +1 -0
  10. package/sensor/dist/graph/anchor-resolve.js +132 -0
  11. package/sensor/dist/graph/anchor-resolve.js.map +1 -0
  12. package/sensor/dist/graph/touched-symbols.d.ts +42 -0
  13. package/sensor/dist/graph/touched-symbols.d.ts.map +1 -0
  14. package/sensor/dist/graph/touched-symbols.js +80 -0
  15. package/sensor/dist/graph/touched-symbols.js.map +1 -0
  16. package/src/cli-help.mjs +28 -6
  17. package/src/cli-refusal-guidance.mjs +3 -0
  18. package/src/function-split-verify.mjs +396 -0
  19. package/src/plan-backchain.mjs +18 -7
  20. package/src/plan-revise.mjs +26 -12
  21. package/src/plan-scope-review.mjs +1 -1
  22. package/src/project-cli.mjs +23 -3
  23. package/src/runtime-front-end.mjs +8 -3
  24. package/src/seam-apply.mjs +2 -2
  25. package/src/sensor-cli.mjs +82 -1
  26. package/src/sensor-resolve.mjs +116 -0
  27. package/src/sensor-touched.mjs +76 -0
  28. package/src/todo-authoring-input.mjs +1 -0
  29. package/src/todo-cli.mjs +303 -27
  30. package/src/todo-contracts.mjs +118 -4
  31. package/src/todo-declaration.mjs +165 -0
  32. package/src/todo-function-split.mjs +234 -0
  33. package/src/todo-gantt-html-independence.mjs +2 -2
  34. package/src/todo-gantt-html-shared.mjs +4 -1
  35. package/src/todo-gantt-html.mjs +4 -2
  36. package/src/todo-independence-authoritative-observation.mjs +26 -23
  37. package/src/todo-independence-contracts.mjs +17 -4
  38. package/src/todo-independence.mjs +4 -1
  39. package/src/todo-judgment.mjs +141 -0
  40. package/src/todo-relation-store.mjs +294 -0
  41. package/src/todo-revision.mjs +5 -5
  42. package/src/todo-split-labels.mjs +26 -0
  43. package/src/todo-split-start.mjs +100 -0
  44. package/src/todo-split-store.mjs +100 -0
  45. package/src/todo-store-view.mjs +3 -2
  46. package/src/todo-store.mjs +31 -14
  47. package/src/witness-scaffold.mjs +23 -15
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ /**
3
+ * Anchor resolution — `{path, symbol}` → the line span(s) of that symbol in that file (ADR 0204 Resolve, a3).
4
+ *
5
+ * Deterministic, no AI. Unlike `lookupSymbolNodes` (a name typed by a human, anywhere in the project) this answers one
6
+ * question: "in THIS file, which definition does this written chain name?". Matching is exact on a boundary-aligned
7
+ * chain; a miss never degrades to a fuzzy hit, it answers the nearest names so the caller can correct the typo.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.resolveAnchors = resolveAnchors;
11
+ exports.lookupNames = lookupNames;
12
+ /** Kinds that are not a unit of change inside a file. */
13
+ const NOT_A_SYMBOL = new Set(['file', 'import', 'export', 'parameter']);
14
+ const NEAREST_LIMIT = 5;
15
+ const ELSEWHERE_LIMIT = 5;
16
+ const RELATED_LIMIT = 20;
17
+ /** Scope separators are `::` in the extractors and `.` in what people write; `/n` is Erlang arity. */
18
+ function chainOf(text) {
19
+ return text.split(/::|\./).filter((part) => part.length > 0);
20
+ }
21
+ const display = (node) => chainOf(node.qualifiedName || node.name).join('.');
22
+ /**
23
+ * Does the node's chain end with the written chain? Leading parts that the extractor does not keep in the name
24
+ * (Rust modules, Python packages live in the path) may instead match a path segment.
25
+ */
26
+ function nodeMatches(node, written, pathSegments) {
27
+ const own = chainOf(node.qualifiedName || node.name);
28
+ for (let tail = written.length; tail >= 1; tail--) {
29
+ const wantedTail = written.slice(written.length - tail);
30
+ if (wantedTail.length > own.length)
31
+ continue;
32
+ const ownTail = own.slice(own.length - tail);
33
+ if (!wantedTail.every((part, i) => part === ownTail[i]))
34
+ continue;
35
+ if (written.slice(0, written.length - tail).every((part) => pathSegments.has(part)))
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ function distance(a, b) {
41
+ const x = a.toLowerCase();
42
+ const y = b.toLowerCase();
43
+ let previous = Array.from({ length: y.length + 1 }, (_, i) => i);
44
+ for (let i = 1; i <= x.length; i++) {
45
+ const row = [i];
46
+ for (let j = 1; j <= y.length; j++) {
47
+ row[j] = Math.min(previous[j] + 1, row[j - 1] + 1, previous[j - 1] + (x[i - 1] === y[j - 1] ? 0 : 1));
48
+ }
49
+ previous = row;
50
+ }
51
+ return previous[y.length];
52
+ }
53
+ function span(path, symbol, node) {
54
+ return { path, symbol, qualified: display(node), kind: node.kind, startLine: node.startLine, endLine: node.endLine };
55
+ }
56
+ function relatedOf(host, node) {
57
+ const take = (rows) => rows.slice(0, RELATED_LIMIT).map(({ node: n }) => ({
58
+ path: n.filePath, symbol: display(n), kind: n.kind, startLine: n.startLine, endLine: n.endLine,
59
+ }));
60
+ const callers = host.getCallers?.(node.id, 1) ?? [];
61
+ const callees = host.getCallees?.(node.id, 1) ?? [];
62
+ return { callers: take(callers), callees: take(callees), truncated: callers.length > RELATED_LIMIT || callees.length > RELATED_LIMIT };
63
+ }
64
+ function nearestIn(nodes, written) {
65
+ const target = written.join('.');
66
+ return nodes
67
+ .map((node) => ({ node, score: distance(target, display(node)) }))
68
+ .sort((a, b) => a.score - b.score || a.node.startLine - b.node.startLine)
69
+ .slice(0, NEAREST_LIMIT)
70
+ .map(({ node }) => ({
71
+ symbol: display(node), qualified: display(node), kind: node.kind, startLine: node.startLine, endLine: node.endLine,
72
+ }));
73
+ }
74
+ function resolveAnchors(host, anchors, options = {}) {
75
+ const out = { resolved: [], unresolved: [], ambiguous: [] };
76
+ const fileCache = new Map();
77
+ for (const anchor of anchors) {
78
+ const path = anchor.path.replace(/^\.\//, '');
79
+ const written = chainOf(anchor.symbol.replace(/\/\d{1,3}$/, ''));
80
+ const miss = (reason, nearest = [], elsewhere = []) => out.unresolved.push({ path: anchor.path, symbol: anchor.symbol, reason, nearest, elsewhere });
81
+ if (path === '' || path.startsWith('/') || path.split('/').includes('..')) {
82
+ miss('path_invalid');
83
+ continue;
84
+ }
85
+ if (written.length === 0) {
86
+ miss('symbol_empty');
87
+ continue;
88
+ }
89
+ let all = fileCache.get(path);
90
+ if (all === undefined) {
91
+ all = host.getNodesInFile(path);
92
+ fileCache.set(path, all);
93
+ }
94
+ const symbols = all.filter((node) => !NOT_A_SYMBOL.has(node.kind));
95
+ const segments = new Set(path.split('/').flatMap((part) => [part, part.replace(/\.[^.]+$/, '')]));
96
+ const hits = symbols.filter((node) => nodeMatches(node, written, segments));
97
+ if (hits.length > 0) {
98
+ for (const node of hits) {
99
+ const resolved = span(path, anchor.symbol, node);
100
+ if (options.related === true)
101
+ resolved.related = relatedOf(host, node);
102
+ out.resolved.push(resolved);
103
+ }
104
+ const names = [...new Set(hits.map(display))];
105
+ if (names.length > 1)
106
+ out.ambiguous.push({ path, symbol: anchor.symbol, names });
107
+ continue;
108
+ }
109
+ const elsewhere = host.getNodesByName(written[written.length - 1])
110
+ .filter((node) => node.filePath !== path && !NOT_A_SYMBOL.has(node.kind))
111
+ .slice(0, ELSEWHERE_LIMIT)
112
+ .map((node) => ({ path: node.filePath, symbol: display(node), kind: node.kind, startLine: node.startLine, endLine: node.endLine }));
113
+ miss(all.length === 0 ? 'file_not_indexed' : 'symbol_not_found', nearestIn(symbols, written), elsewhere);
114
+ }
115
+ return out;
116
+ }
117
+ const NAME_DEFINITION_LIMIT = 5;
118
+ /** Seed fallback (2b): which graph symbols does a bare identifier name? Exact name only, never fuzzy. */
119
+ function lookupNames(host, names) {
120
+ return names.map((name) => {
121
+ const found = host.getNodesByName(name).filter((node) => !NOT_A_SYMBOL.has(node.kind));
122
+ const tooCommon = found.length > NAME_DEFINITION_LIMIT;
123
+ return {
124
+ name,
125
+ tooCommon,
126
+ definitions: tooCommon ? [] : found.map((node) => ({
127
+ path: node.filePath, symbol: display(node), kind: node.kind, startLine: node.startLine, endLine: node.endLine,
128
+ })),
129
+ };
130
+ });
131
+ }
132
+ //# sourceMappingURL=anchor-resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor-resolve.js","sourceRoot":"","sources":["../../src/graph/anchor-resolve.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA+GH,wCAqCC;AAaD,kCAYC;AAzKD,yDAAyD;AACzD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAyCxE,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,sGAAsG;AACtG,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,IAAU,EAAU,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE3F;;;GAGG;AACH,SAAS,WAAW,CAAC,IAAU,EAAE,OAAiB,EAAE,YAAyB;IAC3E,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAA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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjD,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO;aAC9G,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Touched — diff hunks → the symbols they changed (ADR 0204 Touched, a6). Deterministic, no AI.
3
+ *
4
+ * The caller hands the hunks of a commit range (`git diff -U0`) and the index of the range END; each hunk's new-side lines are
5
+ * mapped to the innermost indexed symbols they overlap. What no symbol can carry is never dropped: it comes back in
6
+ * `unattributed` with a reason, so "no symbol" is read as "file-level", never as "touched nothing".
7
+ */
8
+ import type { Node } from '../types';
9
+ export interface HunkInput {
10
+ old_start: number;
11
+ old_count: number;
12
+ new_start: number;
13
+ new_count: number;
14
+ }
15
+ export interface FileChangeInput {
16
+ path: string;
17
+ old_path: string | null;
18
+ status: 'modified' | 'added' | 'deleted' | 'renamed' | 'binary';
19
+ hunks: HunkInput[];
20
+ }
21
+ export interface TouchedSymbol {
22
+ path: string;
23
+ symbol: string;
24
+ kind: string;
25
+ start_line: number;
26
+ end_line: number;
27
+ }
28
+ export interface UnattributedChange {
29
+ path: string;
30
+ reason: 'file_not_indexed' | 'file_deleted' | 'binary' | 'renamed' | 'outside_any_symbol' | 'partly_outside_any_symbol' | 'deleted_outside_any_symbol';
31
+ old_range: [number, number] | null;
32
+ new_range: [number, number] | null;
33
+ }
34
+ export interface TouchedResult {
35
+ touched: TouchedSymbol[];
36
+ unattributed: UnattributedChange[];
37
+ }
38
+ export interface TouchedHost {
39
+ getNodesInFile(filePath: string): Node[];
40
+ }
41
+ export declare function touchedSymbols(host: TouchedHost, files: FileChangeInput[]): TouchedResult;
42
+ //# sourceMapp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AAA;CAAE;AAoBzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,aAAa,CAyCzF"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Touched — diff hunks → the symbols they changed (ADR 0204 Touched, a6). Deterministic, no AI.
4
+ *
5
+ * The caller hands the hunks of a commit range (`git diff -U0`) and the index of the range END; each hunk's new-side lines are
6
+ * mapped to the innermost indexed symbols they overlap. What no symbol can carry is never dropped: it comes back in
7
+ * `unattributed` with a reason, so "no symbol" is read as "file-level", never as "touched nothing".
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.touchedSymbols = touchedSymbols;
11
+ const NOT_A_SYMBOL = new Set(['file', 'import', 'export', 'parameter']);
12
+ const chainOf = (node) => (node.qualifiedName || node.name).split(/::|\./).filter((p) => p.length > 0);
13
+ const display = (node) => chainOf(node).join('.');
14
+ /** `a` holds `b`: range containment, and on equal ranges (a one-line class and its method) the longer chain is the inner one. */
15
+ function holds(a, b) {
16
+ if (a === b || b.startLine < a.startLine || b.endLine > a.endLine)
17
+ return false;
18
+ if (b.startLine > a.startLine || b.endLine < a.endLine)
19
+ return true;
20
+ const ca = chainOf(a);
21
+ const cb = chainOf(b);
22
+ return cb.length > ca.length && ca.every((part, i) => part === cb[i]);
23
+ }
24
+ function innermost(nodes) {
25
+ return nodes.filter((node) => !nodes.some((other) => holds(node, other)));
26
+ }
27
+ const rangeOf = (start, count) => (count > 0 ? [start, start + count - 1] : null);
28
+ function touchedSymbols(host, files) {
29
+ const touched = new Map();
30
+ const unattributed = [];
31
+ const note = (path, reason, old_range, new_range) => unattributed.push({ path, reason, old_range, new_range });
32
+ for (const file of files) {
33
+ if (file.status === 'binary') {
34
+ note(file.path, 'binary', null, null);
35
+ continue;
36
+ }
37
+ if (file.status === 'deleted') {
38
+ note(file.path, 'file_deleted', null, null);
39
+ continue;
40
+ }
41
+ if (file.status === 'renamed' && file.hunks.length === 0) {
42
+ note(file.path, 'renamed', null, null);
43
+ continue;
44
+ }
45
+ const all = host.getNodesInFile(file.path);
46
+ const nodes = all.filter((node) => !NOT_A_SYMBOL.has(node.kind));
47
+ for (const hunk of file.hunks) {
48
+ const oldRange = rangeOf(hunk.old_start, hunk.old_count);
49
+ const newRange = rangeOf(hunk.new_start, hunk.new_count);
50
+ if (all.length === 0) {
51
+ note(file.path, 'file_not_indexed', oldRange, newRange);
52
+ continue;
53
+ }
54
+ // A pure deletion sits between new lines `new_start` and `new_start + 1`; it is inside a symbol only when both belong to it.
55
+ const [first, last] = newRange ?? [hunk.new_start, hunk.new_start + 1];
56
+ const overlapping = nodes.filter((node) => (newRange === null
57
+ ? node.startLine <= first && node.endLine >= last
58
+ : node.startLine <= last && node.endLine >= first));
59
+ if (overlapping.length === 0) {
60
+ note(file.path, newRange === null ? 'deleted_outside_any_symbol' : 'outside_any_symbol', oldRange, newRange);
61
+ continue;
62
+ }
63
+ for (const node of innermost(overlapping)) {
64
+ touched.set(`${file.path}\0${display(node)}\0${node.startLine}\0${node.endLine}`, {
65
+ path: file.path, symbol: display(node), kind: node.kind, start_line: node.startLine, end_line: node.endLine,
66
+ });
67
+ }
68
+ // Lines of an added or changed block that no symbol holds (imports, top-level code next to a function): disclosed, not lost.
69
+ if (newRange !== null && file.status !== 'added') {
70
+ let line = first;
71
+ while (line <= last && overlapping.some((node) => node.startLine <= line && node.endLine >= line))
72
+ line++;
73
+ if (line <= last)
74
+ note(file.path, 'partly_outside_any_symbol', oldRange, newRange);
75
+ }
76
+ }
77
+ }
78
+ return { touched: [...touched.values()], unattributed };
79
+ }
80
+ //# sourceMappingURL=touched-symbols.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"touched-symbols.js","sourceRoot":"","sources":["../../src/graph/touched-symbols.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAqDH,wCAyCC;AA1FD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EA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AI,IAAI,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,OAAO,EAAE,EAAE;oBAChF,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO;iBAC5G,CAAC,CAAC;YACL,CAAC;YACD,6HAA6H;YAC7H,IAAI,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBACjD,IAAI,IAAI,GAAG,KAAK,CAAC;gBACjB,OAAO,IAAI,IAAI,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC;oBAAE,IAAI,EAAE,CAAC;gBAC1G,IAAI,IAAI,IAAI,IAAI;oBAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,2BAA2B,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;AAC1D,CAAC"}
package/src/cli-help.mjs CHANGED
@@ -34,7 +34,7 @@ Commands:
34
34
  create --input <file> [--serialization-reviewed]
35
35
  # 結果へdispatch_shapeを載せる。--serialization-reviewedは互換のため受理するだけで門ではない
36
36
  create --schema --json # 既定は最新版(v5)のJSON Schemaを返す
37
- create --schema-version <1|2|3|4|5> --json
37
+ create --schema-version <1|2|3|4|5|6> --json
38
38
  create --template --json # 作者が書くkeyだけの最小のv5入力(各taskの設計メモを書けばplan createが受理する)
39
39
  backchain --schema --json # 最終成果から必要な機能を逆算する入力契約
40
40
  revise [--plan <key>] --input <file> [--dry-run] [--json]
@@ -137,7 +137,8 @@ Write commands:
137
137
  # 1件を閉じる。planは書き直さず、他のtaskの状態とjournalはそのまま
138
138
  add --plan <key> --task <id> --title <text> [--phase <id>] [--lane <lane>] [--done-condition <text>]
139
139
  [--design-memo <text>] [--after <id>[,<id>...]] [--before <id>[,<id>...]] [--reason <text>]
140
- # 1件を足す(a39)。planの全体を書かずに軽量改訂で新plan_versionを作り、他のtaskはcarry
140
+ [--owns <path>[#<function>][,...]] [--reads <path>[#<function>][,...]]
141
+ # 1件を足す(a39)。planの全体を書かずに軽量改訂で新plan_versionを作り、他のtaskはcarry。--owns/--reads は変える・読む関数を path#関数 で一度だけ宣言する(解決できない名前は行を書かず、近い名前を結果に返す。足すこと自体は失敗しない)
141
142
  done --plan <key> --task <id> [--message <text>] [--test-result <markdown-file>]
142
143
  # taskを閉じる。--messageの文が閉じた記録になる(省略すると既定の文)。--evidence <file>は次のminorまでの別名で、fileの文を--messageとして読む。
143
144
  # 既にdoneなら何も足さずunchanged:trueで成功する(a12)
@@ -168,12 +169,12 @@ Write commands:
168
169
  # enforced = witness+未宣言・古い宣言・衝突・参照なしdone・heavy段階の監査なし閉じを止める(ADR 0200)
169
170
  # このplanの調整方式(witness検証で並列するか、会話で調整するか)を記録する
170
171
  independence compile --plan <key> --input <file> # witness setとsensorから並列可否を記録する
171
- independence compile --schema --json # compileが読むwitness set(lattice.todo_witness_set.v5)のJSON Schema
172
+ independence compile --schema --json # compileが読むwitness set(lattice.todo_witness_set.v5。read_anchorsを使う計画はv6: docs/schemas/lattice.todo_witness_set.v6.schema.json)のJSON Schema
172
173
  independence witness migrate --plan <key> # revision後の宣言をtask migrationで写す
173
174
  independence witness scaffold --template --plan <key> [--json] # 未完の工程を並べた下書きのひな形を出す
174
175
  independence witness scaffold --schema --json # 下書き(lattice.todo_witness_draft.v2)のJSON Schema
175
176
  independence witness scaffold --plan <key> --input <draft> # 下書きとfresh観測から宣言を書き出す
176
- independence witness declare --plan <key> --task <id> [--owns <path>[,<path>...]] [--reads ...] [--writes ...]
177
+ independence witness declare --plan <key> --task <id> [--owns <path>[#<function>][,...]] [--reads <path>[#<function>][,...]] [--writes ...]
177
178
  # 1件のtaskの行だけを宣言する(a40)。宣言済みの行でcompileまで行い、未宣言のreadyはwaiting_forに返す
178
179
  structure input --plan <key> --input <file> --dry-run --json
179
180
  # plan identity・topology・unfinished task coverage・baseline祖先を無変更で検査する
@@ -190,6 +191,8 @@ Write commands:
190
191
  seam-proposal compile --plan <key> # 並列可否記録と実sensorからseam提案を記録する
191
192
  seam-proposal apply --plan <key> # 記録済み提案を隔離worktreeで適用し五条件で採否を決める
192
193
  seam-proposal land --plan <key> --names <file> # 採用された変換を本ツリーへ着地させる
194
+ function-split verify --plan <key> --task <id> --commit <sha> [--base <sha>] --map <task>=<path#function>[,...] # 関数分割工程S: 作業者の切り出しを五条件で検査して記録する
195
+ function-split decline --plan <key> --task <id> --reason <text> # 分けない: Sを閉じ、先に着手した工程の後ろへ他をつなぐ
193
196
  split --plan <key> --input <file> # in-progress ToDoを抽出群とpending残差へrevisionする
194
197
  revise --plan <key> --input <file>
195
198
  revise-phase --plan <key> --input <file>
@@ -227,6 +230,17 @@ todo startのadvisoryとtodo independenceの投影が、その状況と次の一
227
230
  `,
228
231
  sensor: `Usage: lattice sensor <init|sync> [path] [--json]
229
232
  lattice sensor diff <rootA> <rootB> [options] [--json]
233
+ lattice sensor resolve <path#symbol>... [--path <root>] [--related] [--json]
234
+ lattice sensor touched <from> [<to>] [--path <root>] [--json]
235
+
236
+ resolve: path#symbolの関数の行範囲を、維持されている索引から引く(完全一致のみ)。symbolは区切りを.でつないだ
237
+ 入れ子の名前(Bar.baz)で、pathとsymbolは最初の#で分ける。外れたらunresolvedに同じファイルの近い名前
238
+ (nearest)と他ファイルの同名(elsewhere)を返し、終了コードは0。--relatedで直接の呼び出し元と先も添える。
239
+
240
+ touched: <from>..<to>(<to>の既定はHEAD)の差分のhunkを、変えた関数へ写す。touchedは{path, symbol, kind, start_line, end_line}、
241
+ 関数に入らない変更(import、トップ階層、消えた関数、改名、バイナリ、索引にない種類のファイル)はunattributedに
242
+ 理由つきで返し、ファイル単位の変更として扱う。<to>がHEADで作業木がcleanなら維持された索引を使い、そうでなければ
243
+ <to>の使い捨てworktreeで新しく索引する(未commitの状態は見ない)。
230
244
 
231
245
  diff options:
232
246
  --subtree-a <rel> # A側をこの部分木だけに絞り、prefixを剥がしてから突き合わせる
@@ -284,7 +298,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
284
298
  'setup status': 'setup status [--host <claude|codex|grok|cursor|all>] [--json]',
285
299
  status: 'status [--json]',
286
300
  'session-context': 'session-context [--json]',
287
- 'plan create': 'plan create --input <file> [--serialization-reviewed] | --schema --json | --schema-version <1|2|3|4|5> --json | --template --json',
301
+ 'plan create': 'plan create --input <file> [--serialization-reviewed] | --schema --json | --schema-version <1|2|3|4|5|6> --json | --template --json',
288
302
  'plan show': 'plan show <plan_key> --json',
289
303
  'plan scope-review': 'plan scope-review --plan-input <plan-create-or-extraction.json> --review <scope-review.json> --json | --schema --json',
290
304
  'plan backchain': 'plan backchain --input <file> [--dry-run] [--json] | --schema --json',
@@ -347,11 +361,17 @@ const SUBCOMMAND_USAGE = Object.freeze({
347
361
  'todo independence': 'todo independence [--plan <key>] [--json] | mode --plan <key> --set <witness|conversation|enforced> --reason <text>'
348
362
  + ' | compile --plan <key> --input <file> | compile --schema --json | witness migrate --plan <key>'
349
363
  + ' | witness scaffold --template --plan <key> [--json] | witness scaffold --schema --json | witness scaffold --plan <key> --input <draft>'
350
- + ' | witness declare --plan <key> --task <id> [--owns <path>[,<path>...]] [--reads ...] [--writes ...]',
364
+ + ' | witness declare --plan <key> --task <id> [--owns <path>[#<function>][,...]] [--reads <path>[#<function>][,...]] [--writes ...]',
351
365
  'todo independence mode': 'todo independence mode --plan <key> --set <witness|conversation|enforced> --reason <text>',
352
366
  'todo structure': 'todo structure --schema --json | [--plan <key>] --json | input --plan <key> --input <file> [--dry-run --json] | compile --plan <key> --input <file> | realize --plan <key> --task <id> (--planned|--realized <actual-structure.json>) [--commit <HEAD|sha>]... | realize --plan <key> --task <id> --input <full-realization.json> | finalize --plan <key> --json',
353
367
  'todo seam-profile': 'todo seam-profile --plan <key> --file <path> [--json]',
354
368
  'todo seam-proposal': 'todo seam-proposal [--plan <key>] [--json] | compile --plan <key>',
369
+ 'todo function-split': [
370
+ 'todo function-split verify --plan <key> --task <id> --commit <sha> [--base <sha>] --map <task>=<path#function>[,...]',
371
+ 'todo function-split decline --plan <key> --task <id> --reason <text>',
372
+ ].join('\n lattice '),
373
+ 'todo function-split verify': 'todo function-split verify --plan <key> --task <id> --commit <sha> [--base <sha>] --map <task>=<path#function>[,...] # ADR 0205: behaviour, tests, fresh, overlap, parallel on the commit',
374
+ 'todo function-split decline': 'todo function-split decline --plan <key> --task <id> --reason <text> # 分割しない(ADR 0205)',
355
375
  'todo verify': 'todo verify [--plan <key>] [--json]',
356
376
  'todo repair-eol': 'todo repair-eol --json',
357
377
  'todo snapshot': 'todo snapshot --rebuild --plan <key>',
@@ -414,6 +434,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
414
434
  'todo migrate': 'todo migrate --input <extraction.json> [--serialization-reviewed] [--json] | --input <extraction.json> --dry-run --json [--serialization-reviewed] | --schema --json',
415
435
  'sensor init': 'sensor init [path] [--json]',
416
436
  'sensor sync': 'sensor sync [path] [--json]',
437
+ 'sensor resolve': 'sensor resolve <path#symbol>... [--path <root>] [--related] [--json]',
438
+ 'sensor touched': 'sensor touched <from> [<to>] [--path <root>] [--json]',
417
439
  'sensor diff': 'sensor diff <rootA> <rootB> [--subtree-a <rel>] [--subtree-b <rel>]'
418
440
  + ' [--map-a <from>=<to>] [--map-b <from>=<to>] [--limit <n>] [--json]',
419
441
  'runtime-errors snapshot': 'runtime-errors snapshot [--after-cursor <n>] [--limit <n>] --json',
@@ -463,6 +463,9 @@ const REGISTRY = {
463
463
  done_condition_schema_downgrade: {
464
464
  repair: (detail) => `The desired plan schema ${q(detail.desired_schema)} drops done_condition from ${q(detail.predecessor_schema)}: build the desired plan with ${q(detail.predecessor_schema)}.`,
465
465
  },
466
+ function_split_schema_downgrade: {
467
+ repair: (detail) => `The desired plan schema ${q(detail.desired_schema)} drops function_split from ${q(detail.predecessor_schema)}: build the desired plan with ${q(detail.predecessor_schema)}.`,
468
+ },
466
469
  acquire_phase_requires_unassigned_predecessor: {
467
470
  repair: (detail) => `Task ${migratedTask(detail)} already has a phase, so it cannot acquire one: migrate it with policy 'carry' or 'reset' instead.`,
468
471
  },