@quolu/lattice 0.21.0 → 0.21.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.21.0",
3
+ "version": "0.21.1",
4
4
  "description": "Lattice — phase-aware TODO graph compiler and conflict-aware orchestration runtime",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -130,11 +130,35 @@ async function buildPatch(worktreePath, changedPaths) {
130
130
  return Buffer.concat(parts);
131
131
  }
132
132
 
133
+ /**
134
+ * mountのために作った親dirが1エントリで報告されたら、除外せず展開して子を同じ規律で見る。
135
+ *
136
+ * 親ごと除外すると、その中に現れた別の変更まで隠れる。runnerが張ったmountだけを外す規律を、
137
+ * ディレクトリ単位の報告でも保つ。
138
+ */
139
+ async function expandMountAncestors(worktreePath, paths, mountedEntries) {
140
+ const isAncestor = (entry) => mountedEntries
141
+ .some((mount) => mount.startsWith(`${entry}/`));
142
+ const expanded = [];
143
+ const pending = [...paths];
144
+ while (pending.length > 0) {
145
+ const current = pending.pop();
146
+ const normalized = current.replace(/\/$/u, '');
147
+ if (!current.endsWith('/') || !isAncestor(normalized)) { expanded.push(current); continue; }
148
+ const children = await readdir(path.join(worktreePath, normalized), { withFileTypes: true });
149
+ for (const child of children) {
150
+ pending.push(`${normalized}/${child.name}${child.isDirectory() ? '/' : ''}`);
151
+ }
152
+ }
153
+ return [...new Set(expanded)].sort();
154
+ }
155
+
133
156
  async function captureSnapshot(worktreePath, baseSha, allowedPaths, mountedEntries = []) {
134
157
  const mounted = new Set(mountedEntries);
135
- const changedPaths = statusPaths((await run('git', [
158
+ const reported = statusPaths((await run('git', [
136
159
  'status', '--porcelain=v1', '-z', '--untracked-files=all', '--ignored=matching',
137
- ], { cwd: worktreePath })).stdout)
160
+ ], { cwd: worktreePath })).stdout);
161
+ const changedPaths = (await expandMountAncestors(worktreePath, reported, [...mounted]))
138
162
  // runnerが張ったmountだけを外す。それ以外は無視しない——gitignore対象であっても、
139
163
  // allowed pathの外に現れたものは変更である。
140
164
  .filter((changedPath) => {